Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>THIS NO LONGER WORKS. GO HERE, <a href="https://stackoverflow.com/a/11102147/704647">https://stackoverflow.com/a/11102147/704647</a></p> <p>So with some more research, I was able to cobbled together a solution to this problem. In order to do it, I needed to use a combination of the graph API and the legacy REST api. After granting permission to my app to post to my wall, I used the following code to post the entries on my website by my users to my wall.</p> <pre><code>$url = "https://graph.facebook.com/oauth/access_token"; $client_id = "XXXXXXXXXXXXXX"; $client_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"; $postString = "client_id=$client_id&amp;client_secret=$client_secret&amp;type=client_cred"; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_FAILONERROR, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $postString); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $token = curl_exec($curl); curl_close($curl); $message = rawurlencode($description.'. Notes:'.$notes); $url = "https://api.facebook.com/method/stream.publish"; $postString = "message=$message&amp;uid=XXXXXXXXXXXXX&amp;$token"; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_FAILONERROR, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $postString); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); curl_close($curl); </code></pre> <p>Few things worth noting. 1. The uid in the rest api $postString is the uid for your facebook PAGE. You do not need a target_id because when the uid is of a page it can only publish to itself. 2. Your $message must be rawurlencoded because that is the form accepted by the rest api. 3. This will post to your page as your APP, not as the user who made the post to your website. To do that you would need to have the publish_stream permission from all of your users. Or use the ui dialog to get it with each post. Both of those seem like overkill if all you want to do is post to your OWN page wall.</p> <p>Since I have seen variations of this question unanswered on stackoverflow in numerous places (I posted this answer on one) I figured it was worth posting this answer here.</p> <p>If you are unsure as to how to grant your app permission to post to your facebook page wall, here are the two step you need to take. I got this from <a href="https://stackoverflow.com/questions/2097665/authorizing-a-facebook-fan-page-for-status-updates/2110437#2110437">this post</a> </p> <p>I first had to authorize offline access with this url (replacing 'MYAPIKEY'): <a href="http://www.facebook.com/login.php?api_key=MYAPIKEY&amp;connect_display=popup&amp;v=1.0&amp;next=http://www.facebook.com/connect/login_success.html&amp;cancel_url=http://www.facebook.com/connect/login_failure.html&amp;fbconnect=true&amp;return_session=true&amp;session_key_only=true&amp;req_perms=read_stream,publish_stream,offline_access" rel="nofollow noreferrer">http://www.facebook.com/login.php?api_key=MYAPIKEY&amp;connect_display=popup&amp;v=1.0&amp;next=http://www.facebook.com/connect/login_success.html&amp;cancel_url=http://www.facebook.com/connect/login_failure.html&amp;fbconnect=true&amp;return_session=true&amp;session_key_only=true&amp;req_perms=read_stream,publish_stream,offline_access</a></p> <p>Then, I needed to grant 'publish_stream' permissions to the PAGE with this url (replacing 'MYAPIKEY' and 'THEPAGEID'): <a href="http://www.facebook.com/connect/prompt_permissions.php?api_key=MYAPIKEY&amp;v=1.0&amp;next=http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&amp;display=popup&amp;ext_perm=publish_stream&amp;enable_profile_selector=1&amp;profile_selector_ids=THEPAGEID" rel="nofollow noreferrer">http://www.facebook.com/connect/prompt_permissions.php?api_key=MYAPIKEY&amp;v=1.0&amp;next=http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&amp;display=popup&amp;ext_perm=publish_stream&amp;enable_profile_selector=1&amp;profile_selector_ids=THEPAGEID</a></p> <p>Hope this helps somebody.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload