Facebook Open Graph - post to all approved users feeds
I'm struggling to get to grips with posting a feed item to all the members of an approved application.
Within the application settings for the user it is stating that the application has permission to post to the wall but I can only achieve this if that user is currently logged in to facebook. Obviously I would like this to function so that any items I uploaded are posted to all the members of the application at any one time.
I am using the Facebook PHP SDK from http://github.com/facebook/php-sdk/ and currrently my code is as follows:
require 'src/facebook.php';
//Generates access token for this transaction
$accessToken = file_get_contents("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=MyAppId&client_secret=MySecret");
//Gets the full user details as an object
$contents = json_decode(file_get_contents("https://graph.facebook.com/SomeUserId?scope=publish_stream&" . $accessToken));
print_r($contents);
if ($facebook->api('/' . $contents->id 开发者_StackOverflow社区. '/feed', 'POST',
array(
'title' => 'New and Improved, etc - 12/03/2010',
'link' => 'http://www.ib3.co.uk/news/2010/03/12/new-and-improved--etc',
'picture' => 'http://www.ib3.co.uk/userfiles/image/etc-booking.jpg',
'scope' => 'publish_stream'
)
)==TRUE) {
echo "message posted";
} else {
echo "message failed";
}
The output from $contents
shows the expected user details but nothing relating to the permissions for my application. Am I missing a trick here?
Then using the $facebook->api()
function I am receiving a
200 - Permissions error
. The application does not have permission to perform this action.
This is driving me a little potty as I suspect I'm missing something straightforward with the authorisation but what?
Many thanks in advance for an assistance offered.
I had the same problem yesterday. Finally I figured out that, although I had set checked the "permission to post to wall", I had to do this step also:
https://graph.facebook.com/oauth/authorize?client_id=XXXXXXX&scope=publish_stream&redirect=http://back.to.your.app/
There, the end-user will be served with the familiar Facebook "Allow this application to access your information?" dialog. After allowing, it will come back to your app, which then will have the proper permissions.
Hope this helps!
精彩评论