I'm using below code to post to my facebook page as page
$post_id = $facebook->api("/$page_id/feed","post",$args);
I want to make a comment to the post I created. I don't know how to do that exactly. But based on some research, I tried below code and it didn't work.
$comment_id = $facebook->api("/$post_id/comments?message='This is m message'");
An echo or print_r for $comment_id doesn't return anything.
How can I accomplish it i.e. posting comment to a post on my Facebook page using Facebook graph API for PHP? Kindly guide me in the right direction.
Try something like this,
$facebook ->api('/'.$post_id.'/comments',
'post',
array(
'access_token' => $your_access_token_variable,
'message' => 'Your message',
)
);
I'm having a problem when trying to post a link to a friends wall using the Facebook graph from my application.
I am currently using the Facebook SDK for PHP, I have no problems posting to the wall of the user that's logged in but cannot post to friends of the logged in user.
I have requested the extended permission "publish_stream" and here is the code am I using:
$args = array('message' => $message,
'link' => 'google.com',
'name' => 'Test!',
'caption' => 'Please click on the link',
'description' => 'description');
$result = $facebook->api("/$friendId/feed", 'POST', $args );
$friendId has the facebook id of the friend of the logged in user, any help would be much appreciated.
A quick scan of the FB API reference shows that you can set the to key value pair in this operation to
mention or target a user in this post
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.
How can I add information about read article on my site to facebook RECENT ACTIVITY (like the Guardian)?
I use php and code:
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'link' => 'example.com',
'message' => 'Test message'
));
This code posting the message in user's timeline but I want to post message in his recent activity.
probably you wan't to use open graph api, not graph api
https://developers.facebook.com/docs/opengraph/
https://developers.facebook.com/docs/opengraph/tutorial/
https://developers.facebook.com/docs/opengraph/opengraph-approval/
Posting a message on friend's wall, graph API.
i have the publish_stream extended permission of the user, who is using the application.
the code workds if i want to post sth on my wall.
is there any method to post on wall or send message to all the friends of a particular user??
please help thanks!!
following is the code, but it is not working.
$friends = $facebook->api('/me/friends');
foreach($friends['data'] as $friend){
$friendsUserId = $friend['id'];
echo $friendsUserId . "</br>";
$result = $facebook->api('/$friendsUserId/feed', 'POST', array(
message' => 'Test Message' ));
print_r($result);
}
This would perhaps be the way to do it.. (Untested, but I use something similar for my app.)
$friends = $facebook->api('/me/friends');
foreach($friends['data'] as $friend) {
$facebook->api('/$friend['id']/feed', 'post', array(
'message' => 'just a test message',
'link' => 'http://site.com',
'name' => 'just a test name',
'caption' => 'just a test caption',
'description' => 'just a test description',
));
}
This is using the PHP API.
I just did a little testing, and having the permissions of the user, I could indeed post on the user's friends walls via the php api:
$facebook->api('/[FRIEND_ID]/feed', 'post', array(
'message' => 'test message',
'link' => 'http://google.com',
'name' => 'test name',
'caption' => 'test caption',
'description' => 'test long description',
));
The publish_stream permission only allows you to publish content on that particular users wall - you cannot post on the wall of all his friends.
Think about it this way - say you have not authorized an application to post anything on your facebook wall but just because one of your friends has given access to his wall - it automatically does not give the application access to publish on the wall of all his friends.
EDIT
Rahul, I tried yesterday night to login as myself and post a message on the wall of one of my friends through my app and surprisingly it worked. I was under the wrong impression that you could not do that. My apologies.
But I'm still not able to figure this out. Let me explain
1) I have my real facebook lets call it abc and a test facebook account xyz which I've added as my friend to abc
2) I login into my app using my abc faceboook account and publish a message on the wall of my friend xyz
3) Now I login to facebook.com as abc and it shows on my news feed the message that I published on xyz's wall. When I click on xyz's profile - the message shows up on his wall too. So far so good
4) Now I log out of facebook.com as abc and log back in as xyz. But now I dont see the message that was posted through the app on the wall of xyz.
I dont know if there is any kind of delay but I've waited 30 mins but still its not there. But it continues to show when I log in as abc.
I hope you understand what I'm trying to convey here.
I've used the same piece of code like yours - so can you try the above scenarios and see if you experience something similar
Thanks
Gubloo's answer is close.
Posting to a friend's wall is completely possible, but with one caveat, said friend must have also gone through the 'Permissions' dialogue at some point. Meaning, users of your application will be able to post to the wall's of other users of your application.
I'm going to give you the iPhone code, because I don't know php and imagine you'll get the gist. Just replace 'me' with the UID of whatever you are trying to post to, be a page, or a Friend's profile.
[_facebook requestWithGraphPath:#"/me/feed"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
I'm actually curious to know if this would give the user the ability to post on the wall of anyone who uses the application, and not just his friends.
$friends = $facebook->api('/me/friends');
foreach($friends['data'] as $friend) {
$facebook->api('/$friend['id']/feed', 'post', array(
'message' => 'just a test message',
'link' => 'sample link.com',
'name' => 'just a test name',
'caption' => 'just a test caption',
'description' => 'just a test description',
));
}
Above code work for me tooooo
Thanks for the post