Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook API php - Post a news item to a facebook group
    text
    copied!<p>*<em>strong text</em>*I have a website that publishes articles every day. </p> <p>I want to have a corresponding Facebook group that I can publish the articles to at the same time as on my site. </p> <p>I have set up a similar arrangement in twitter using the api. When I publish an article to my site I it automatiaclly posts the headline and link back to twitter via the twitter API. I would like to have a similar arrangement for my facebook group.</p> <p>Is it possible to have my stories forwarded to my facebook group wall? </p> <p><strong>EDIT</strong></p> <p>Ok, I have gotten this far, and no further:</p> <p>Step 1: Get authorisation to publish to the stream</p> <pre><code>if ($fp = fopen('https://graph.facebook.com/oauth/access_token?client_id=XXXXXXXXXX&amp;client_secret=XXXXXXXXXXXXtype=client_cred&amp;scope=publish_stream', 'r')) { $content = ''; // keep reading until there's nothing left while ($line = fread($fp, 1024)) { $content .= $line; } $tokens = explode("access_token=",$content); // do something with the content here $auth_token = $tokens[1]; fclose($fp); } else { // echo" an error occured when trying to open the specified url"; } </code></pre> <p>Step 2: send my message to the stream using my authorisation code (I have chosen to use cURL):</p> <pre><code> $message="This will be a post on my groups wall."; $url = "https://graph.facebook.com/my_app_id/feed"; $data = array('message' =&gt; $message, 'auth_token' =&gt; $auth_token); $handle = curl_init($url); curl_setopt($handle, CURLOPT_POST, true); curl_setopt($handle, CURLOPT_POSTFIELDS, $data); curl_setopt($curl_handle,CURLOPT_URL,$url); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); $buffer = curl_exec($curl_handle); curl_close($curl_handle); if (empty($buffer)) { print "Nothing seems to have happened"; } else { print $buffer; } </code></pre> <p>The code runs with no errors, but nothing gets returned and nothing gets posted to the wall</p> <p>any ideas?</p>
 

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