I have created an app, and now i want to post a message on one of my friends wall with use of the new Graph API. Is this do-able?
I am already using oAuth and the Gr
To clarify, 'post' here refers to the HTTP method, as in GET/POST. See https://github.com/facebook/php-sdk/blob/master/src/base_facebook.php : protected function _graph($path, $method = 'GET', $params = array())
$result = $facebook->api( '/me/feed/', 'post', array('access_token' => $this->access_token, 'message' => 'Playing around with FB Graph..') );
You'll need the "publish_stream" extended permission in order to write to the feed. Here is a complete list of them: http://developers.facebook.com/docs/authentication/permissions.
In order to get the extended permission, get the authorization token in this way:
https://graph.facebook.com/oauth/authorize?
client_id=...&
redirect_uri=http://www.example.com/callback&
scope=publish_stream
Okay, I finally solved this. Thanx to phpfour for your help :-)
First: My connection-url looks like this (with "publish_stream"):
$connectUrl = $this->getUrl(
'www',
'login.php',
array_merge(array(
'api_key' => $this->getAppId(),
'cancel_url' => $this->getCurrentUrl(),
'req_perms' => 'publish_stream',
'display' => 'page',
'fbconnect' => 1,
'next' => $this->getCurrentUrl(),
'return_session' => 1,
'session_version' => 3,
'v' => '1.0',
), $params)
);
Second; I tried to post to facebook via
$result = $facebook->api(
'/me/feed/',
array('access_token' => $this->access_token, 'message' => 'Playing around with FB Graph..')
);
But the correct way to do this is include one more parameter ('post'):
$result = $facebook->api(
'/me/feed/',
'post',
array('access_token' => $this->access_token, 'message' => 'Playing around with FB Graph..')
);
In addition to chf,
After posting:
$getLinkToken='https://graph.facebook.com/oauth/access_token'.
'?client_id=YOUR_APPID'.
'&redirect_uri=YOUR_SITE'.
'&client_secret=YOUR_SECRET'.
'&code=CODE_KEY';
I got the response:
https://graph.facebook.com/oauth/access_token?
client_id=xxxxxxxxxxxxxx
&redirect_uri=myurl
&client_secret=xxxxxxxxxxxxxx
&code=xxxxxxxxxxxxxx
no which one is access_token
, client_secret
or code
$facebook->api( '/YOUR_APPID/feed/', 'post',
array('access_token' => $this->access_token,
'message' => 'Playing around with FB Graph..'));
Instead of using the below code
[facebook dialog:@"feed"
andParams:params
andDelegate:self];
Use the following solution
[facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];
That is old way to get acces. In GRAPH first i generated code key with:
$getLinkCode ='https://graph.facebook.com/oauth/authorize'.
'?client_id=YOUR_APPID'.
'&redirect_uri=YOUR_SITE'.
'&scope=publish_stream';
And now when we have code key we can generate access_token from link:
$getLinkToken='https://graph.facebook.com/oauth/access_token'.
'?client_id=YOUR_APPID'.
'&redirect_uri=YOUR_SITE'.
'&client_secret=YOUR_SECRET'.
'&code=CODE_KEY';
But this access_token post your message as USER not APPLICATION... WHY?!
If you want post on application wall use:
$facebook->api( '/YOUR_APPID/feed/', 'post', array('access_token' => $this->access_token, 'message' => 'Playing around with FB Graph..'));