I am building a facebook app, in which I am writing user wall using face book graph api.
Now I would like to include more than 1 links in the message . Is it possible,how can I do it.
This is my code
$facebook->api('/'.$uid.'/feed', 'post', array(
'message' => 'Dear friend, I have given '.$input['rate']." to the movie". $moviedetails['ftitle']. "from ReelReview",
'name' => $moviedetails['ftitle'],
'description' => $moviedetails['description'],
'caption' => 'ReelReview - the best movie review app',
'picture' => 'http://site.com/Movie.jpg',
'link' => 'http://mysite.com'
));
Now I am trying to include some links in the message and description,
Thanks in advance
You can only have one 'link' per wall post , however you could include several links in your description.
The difference is that the 'link' property will be the link that facebook scans for information, and displays images and so forth.
The links in the description will look like in a normal message.
Related
Im using the Facebook SDK Api [PHP] to post automaticly on a timeline wall.
I created a App and requested the access_token with the following permissions: manage_pages,publish_stream,offline_access.
Im using now the access_token to post the message on a page (/PAGEID/feed) where im moderator.
The following is going OKAY and get the post working under the name of the Facebook page:
$attachment = array(
'access_token' => $accessToken,
'message' => $description,
);
$res = $facebook->api('/PAGEID/feed', 'POST', $attachment);
When Im adding some link + name AND/OR picture it will post not as wall post but as "recent message of others" with as name my own user:
$attachment = array(
'access_token' => $accessToken,
'message' => $description,
'link' => 'http://www.google.nl',
'name' => $description,
'picture' => $image,
);
How can I post full messages with link and picture on the wall self?
If I understand you correctly, you are trying to post as the Page but it's showing up as a post by you. Is that correct?
If so, I think you need to post using the Page's access token, rather than your own access token. Look at the section called "Page Access Tokens" on https://developers.facebook.com/docs/reference/api/page/. Once you get the page's access token using the technique described there, you can set it to be the token that PHP SDK uses by doing $facebook->setAccessToken(.... access token value ...). Then you can do the post and it should show up as having been created by the page.
This problem troubled me for so long. Everything seemed setup correctly but as soon as I added a link, it would post as Admin instead of Page. The answer above by triangle_man solved my problem. When using the PHP sdk, the specific line of code I needed was:
$page_token = $facebook->api("/$page_id?fields=access_token");
I'm posting on my fanpage but i want to do highlight posts. Any suggestions?
I have to star them one by one on the fanpage. Is there any way to do this? I also read the documentation but there is no examples.
http://developers.facebook.com/docs/reference/api/page/#posts
Sample of code:
$args = array(
'access_token' => $page_info['access_token'],
'message' => 'MY MESSAGE'
);
$post_id = $facebook->api("/MY PAGE ID/feed","post",$args);
Im using PHP SDK 3.1.x.
Use:
POST /<post_id>/ with param timeline_visibility = starred
timeline_visibility must be one of the following values: hidden, normal, starred.
Also see https://stackoverflow.com/a/19861323/1784062.
I have a question, It might be found somewhere but I couldnt find a thread for it so if there is one, please post the link.
I admin a page that is a group of several other business areas. I want to post on one page with different icons and names, can that be done? Like different admins but administered by one person/account?
Possible?
What you are going to want to do is use a "Page access_token". To get this you will have to create an application and grant it the manage_pages permission.
You should see in the Authentication Documentation a section called "Page Login".
You can grant your application the manage_pages permission by going to this URL:
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=manage_pages&response_type=token
Don't forget to substitute YOUR_APP_ID and YOUR_URL with the correct values for you application and URL. (the URL can be any URL - it is where Facebook will send you after you close the Dialog). You will see a dialog that looks something like this :
Once you have the correct permission, you'll want to make a call to this URL :
https://graph.facebook.com/me/accounts?access_token=TOKEN_FROM_ABOVE
You will get a response similar to :
As you can see from the image, you will receive a list of all the pages that the user administers along with an access_token for each page.
You use this access_token to make posts on behalf of the page. Since you have not stated what programming language you are using I will give an example in php.
In php, posting to the page would look something like this :
$facebook->setAccessToken(ACCESS_TOKEN_YOU_RETRIEVED_EARLIER);
$attachment = array('message' => 'this is my message',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'link' => 'http://mylink.com',
'description' => 'this is a description',
'picture' => 'http://mysite.com/pic.gif',
'actions' => array(array('name' => 'Get Search',
'link' => 'http://www.google.com'))
);
$result = $facebook->api('/PAGE_ID/','post',$attachment);
Hope this helps!
Happy coding!
Is there any way to post something to a user's friend's wall from that user in my facebook app?
Example: A user of my facebook app answers a question about one of his friends. I want a small message to be posted to the wall of that friend saying 'Bob answered a question about you...'
Is that possible? If so, how?
It seems that this is possible, the following code is working:
$result = $facebook->api('/$friendsUserId/feed', 'POST', array(
'name' => 'TEST NAME',
'caption' => 'Test Caption',
'description' => 'Test Description',
'message' => 'this is a test.',
));
print_r($result);
die;
I wanted to post a feed to a friends wall from my app and set it as private, which is viewable to the logged in user and the friend.
I want to do this using the new Graph api, I saw that if I set the "to" parameter in the feed post, it will be posted to the users friend wall.
I found a code here:
http://forum.developers.facebook.net/viewtopic.php?id=56458
(Posted by VovaOnline)
(link is dead, as facebook has taken down the forum)
$result = $facebook->api('/me/feed', 'POST', array(
'from' => array(
'name' => 'Vladimir Ageenko',
'id' => '100001308281502'
),
'name' => 'TEST NAME',
'caption' => 'Test Caption',
'description' => 'Test Description',
'message' => 'This is test.',
'privacy' => array(
'description' => 'Vladimir Sergeevich',
'value' => 'CUSTOM',
'friends' => 'SOME_FRIENDS',
'allow' => '100001338940933'
)
));
I am setting the post type as "link".
Can anyone tell me what is wrong in this code. One thing I know that "from" field has to be "to" and it has to be passed in a "data" variable. I am not sure how to do it.
Can any one help me?
You must encode privacy array, try this:
$privacy = array(
'description' => 'Vladimir Sergeevich',
'value' => 'CUSTOM',
'friends' => 'SOME_FRIENDS',
'allow' => '100001338940933'
);
$result = $facebook->api('/me/feed', 'POST', array(
'from' => array(
'name' => 'Vladimir Ageenko',
'id' => '100001308281502'
),
'name' => 'TEST NAME',
'caption' => 'Test Caption',
'description' => 'Test Description',
'message' => 'This is test.',
'privacy' => json_encode($privacy)
));
I don't think Facebook allows you to do this currently. Look at the graph API docs on Posting:
http://developers.facebook.com/docs/reference/api/post/
it says on privacy:
"Note: This privacy setting only applies to posts to the current or specified user's own Wall. Facebook ignores this setting for targeted Wall posts (when the user is writing on the Wall of a friend, Page, event, group connected to the user). Consistent with behavior on Facebook, all targeted posts are viewable by anyone who can see the target's Wall. "
I interpret this to mean that if you post on someone else's wall (feed), privacy is out of your control.
From now on it's not possible to post on user's friend wall due to February 6, 2013 breaking changes:
https://developers.facebook.com/roadmap/completed-changes/
Removing ability to post to friends walls via Graph API We will
remove the ability to post to a user's friends' walls via the Graph
API. Specifically, posts against [user_id]/feed where [user_id] is
different from the session user, or stream.publish calls where the
target_id user is different from the session user, will fail. If you
want to allow people to post to their friends' timelines, invoke the
feed dialog. Stories that include friends via user mentions tagging or
action tagging will show up on the friend’s timeline (assuming the
friend approves the tag). For more info, see this blog post.