*strong text*I have a website that publishes articles every day.
I want to have a corresponding Facebook group that I can publish the articles to at the same time as on my site.
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.
Is it possible to have my stories forwarded to my facebook group wall?
EDIT
Ok, I have gotten this far, and no further:
Step 1: Get authorisation to publish to the stream
if ($fp = fopen('https://graph.facebook.com/oauth/access_token?client_id=XXXXXXXXXX&client_secret=XXXXXXXXXXXXtype=client_cred&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";
}
Step 2: send my message to the stream using my authorisation code (I have chosen to use cURL):
$message="This will be a post on my groups wall.";
$url = "https://graph.facebook.com/my_app_id/feed";
$data = array('message' => $message, 'auth_token' => $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;
}
The code runs with no errors, but nothing gets returned and nothing gets posted to the wall
any ideas?
Facebook treats pages similar to the way they treat people, you specify a UID which is associated with the Page ID of your group. Then just use Facebook’s Graph API to post to the stream, just as you would a person.
To authorize, you get Facebook API permission from an admin and request the
manage_pagespermission.All of the information you need is contained here: https://developers.facebook.com/docs/reference/api/#impersonation.
(Ctrl+F
Page Loginfor more information on authorizing to update to pages).