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)
));