Facebook PHP SDK post activity - php

I am trying to post to a users Activity feed on Facebook using the PHP SDK, is this possible? Or only with Javascript?
Here is my basic code to post to a users wall:
$facebook->api('/me/feed', 'POST',
array(
'link' => 'www.example.com',
'message' => 'Posting with the PHP SDK!'
));
I want to post to a users activity, how is this done? I've experimented with the code below but to no success.
$facebook->api('/me/application:view', 'POST',
array(
'item' => 'www.example.com',
));
Can anyone shed any light on this?

I'm not using opengraph in my apps right now, but hope this helps:
https://developers.facebook.com/docs/opengraph/tutorial/#publish
Also check this answer (there is an example in PHP):
https://stackoverflow.com/a/11383901/173299
Hope it helps you.

Related

Posting Message using Facebook API

Couldn't find this anywhere on Stack overflow, I just don't know what to do.
I just want to place a message on my community Facebook page using the Facebook PHP API, where to get started?
Example:
I click a button on my website, which then automatically posts 'I clicked the button' on my Facebook (community) page.
Thanks in advance!
There is documentation for what you need.
$session, 'POST', '/me/feed', array(
'link' => 'www.example.com',
'message' => 'User provided message'
)
Change /me/feed to the page you want.

facebook PHP SDK posting as activity, not post

I hope you will be able to help me.
I'm developing an app, and I'm willing to post an activity (that appears on user timeline in recent activity) everytime the user use my application.
Although, for the moment, I have this code below, and it only posts a normal link :
if($can_post){
$facebook->api('/'.$uid.'/feed', 'post', array(
'message' => '',
'name' => 'Name',
'caption' => 'Caption',
'description' => 'SDesc',
'picture' => 'picture url',
'link' => 'link',
'actions' => array(array('name' => 'catch phrase',
'link' => 'http://link'))
));
Check out this guide on posting "stories" to the user's timeline using the Open Graph API, so maybe it's this functionality that you need. The example they give is just a like, but it can be easily modified.
Be aware that Facebook will have to approve you app again if you want to use stories (see end of page on link above).
It's also worth noting that Facebook have also defined a wide range of predefined "Actions" to help in the process, so it's a good idea to check to see if your app falls into one of these categories.

Unsupported method, post while using facebook score api

My problem is, while i post score using facebook php sdk it alwasys give error as Unsupported method, post.
Here is the code I use:
$app_AccessToken = $obj_facebook->getAccessToken();
$obj_facebook->api('/100003470602309/scores/', 'post ', array('access_token' => $app_AccessToken, 'score' => '154125'));
use some thing like
$obj_facebook->api('/me/scores', 'POST', array( 'score' => 100, 'access_token' => $obj_facebook->getAppId().'|'.$obj_facebook->getApiSecret() ));
try this :p may be it will help
It could be due to access token. Make sure you have an app access token.

How do I post to a Facebook timeline?

I have an app which uses the Facebook PHP SDK. It used to be a simple matter to post to a user's Facebook wall. I would do the authentication, and then something like:
$ret_obj = $Facebook->api('/me/feed', 'POST',
array(
'link' => 'www.example.com',
'message' => 'Posting with the PHP SDK!'
));
and on their wall the link would appear. Since Timeline was introduced, however, this doesn't seem to work. I don't get an error, I just don't get anything back. I can't find any helpful documentation on how this should work.
More info
I don't get any error, I just get "NULL" returned in $ret_obj.
If I do something like
$ret_obj = $Facebook->api('/me', 'GET');
then it works fine - I get the user's information back. So it's connecting ok, just not posting.
Double check that you have allowed publish_stream permission.
You can refer to PHP SDK and JavaScript SDK Feed Dialog for more examples.
Official Documentation: http://developers.facebook.com/docs/reference/dialogs/feed/

Update facebook status using php

I know it's a very old question.But i really bound to ask the same question again.How can i update my status using PHP?Because i find several solutions in google and stackoverflow but non of that currently works.May be the cause of facebook up gradation process or anything else.
I chk:
1) http://360percents.com/posts/php-curl-status-update-working-example-sep-2010/
2) http://www.barattalo.it/2010/03/01/php-curl-bot-to-update-facebook-status/
But unfortunately non of the solution is working.So, is their any kind heart who can help me to update the facebook status using php easily?i shall be very much glud if anybody pls give any working solution. Regards---riad
Well, I've wrote a tutorial about posting to the user's wall: How To: Post A Message On The User Wall Using Facebook Graph API.
$args = array(
'message' => 'Hello from my App!',
'link' => 'http://www.masteringapi.com/',
'caption' => 'Visit MasteringAPI.com For Facebook API Tutorials!'
);
$post_id = $facebook->api("/me/feed", "post", $args);
Notes:
I'm using the PHP-SDK
You need the publish_stream permission
Check out this answer
What about checking directly the Facebook API ?
http://developers.facebook.com/docs/
Check the "Graph API"
The Graph API is the core of Facebook Platform, enabling you to read and write data to Facebook. It provides a simple and consistent view of the social graph, uniformly representing objects (like people, photos, events, and pages) and the connections between them (friendships, likes, and photo tags).
I wrote this code im my blog completely pl check that in the following link
http://scriptime.blogspot.in/2012/12/facebook-status-updates-using-php-sdk.html
here i am giving samll code
$status = $_POST['status'];
$facebook_id = $userdata['id'];
$params = array(
'access_token' => $access_token,
'message' => $status
);
$url = "https://graph.facebook.com/$facebook_id/feed";
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_POSTFIELDS => $params,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_VERBOSE => true
));

Categories