Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7908957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:10:13+00:00 2026-06-03T12:10:13+00:00

I took this code from Facebook’s documentation to get me started in learning how

  • 0

I took this code from Facebook’s documentation to get me started in learning how to get my app to post to a feed.

It works as described, in that when I go to my app’s canvas URL, I am presented with a dialog where I can enter in text, click “share”, and it posts into my timeline. So far, so good.

But I want to alter it so that instead of explicitly typing something in and clicking a button, a post is automatically sent to the feed, triggered be events in my PHP code.

However, and I realize this is a newbie kind of question, I can’t figure out how to adjust the code to make that happen. My experiments either just break the code or end up with the same dialog.

How do I get the PHP to post a message straight into the feed, and then display the app’s canvas URL immediately after (so as not to get caught in a loop of constantly reloading and posting over and over…)?

For convenience, here is the same code from the Facebook documentation:

<?php 

         $app_id = "YOUR_APP_ID";

         $canvas_page = "YOUR_CANVAS_PAGE_URL";

         $message = "Apps on Facebook.com are cool!";

         $feed_url = "https://www.facebook.com/dialog/feed?app_id=" 
                . $app_id . "&redirect_uri=" . urlencode($canvas_page)
                . "&message=" . $message;

         if (empty($_REQUEST["post_id"])) {
            echo("<script> top.location.href='" . $feed_url . "'</script>");
         } else {
            echo ("Feed Post Id: " . $_REQUEST["post_id"]);
         }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:10:15+00:00Added an answer on June 3, 2026 at 12:10 pm

    You may achieve this by requiring publish_stream permission (see Publishing Permissions).

    Once your app have that permission granted by user you may publish feed stories without showing Feed Dialog to user.

    This also allow you to publish content to user’s feed without need of user’s active access_token and using application access_token for that purpose.

    It’s really easy to implement this using PHP-SDK:

    $facebook = new Facebook(/*...*/);
    
    $facebook->api('/USER_ID/feed', 'post', array(
      'message'=>'Text entered by user'
    ));
    

    Probably publish_actions permission can be sufficient for that task, but documentation isn’t yet updated across developers site so it’s safer to use publish_stream (see statuses for user object).

    The publish_stream permission is a superset of publish_actions allowing everything that publish_actions allows plus more. Some of the additional publishing capabilities are:

    • posting to a friend’s feed
    • posting questions
    • creating notes
    • posting content to events or groups
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i use this code to get image from facebook profile and show it on
I took this code from another question and now I'm trying to get the
Ok i have this piece of code from which i took from W3schools :-
So, I took some code from this Microsoft provided Example which allows me to
I took this from Google Code Playground http://code.google.com/apis/ajax/playground/ /*CLOSURE * When a function is
I took the code from this example. http://msdn.microsoft.com/en-us/library/2tw134k3.aspx What I am wondering (and I've
i took this code from a different question and my script file has more
I took some code from my C# Windows form app which uses the Application
I get this error when I run my code. This is a continuation from
i took this code from msdn string connString = Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;; using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.