How to set properties for post while posting news feed using graph api
I am trying to set properties of post. And I am posting news feed using 开发者_如何学Ccurl.
I am setting properties like this but it is not working.
$message = 'Message 1';
$caption = 'Caption 1';
$media["properties"] = array('category' => array( 'text' => 'humor', 'href' => 'http://www.icanhascheezburger.com/category/humor'));
$media["media"] = array("type" => "image", "src"=> $imageUrl , "href"=>$link);
$attachment = array ('name' => $caption,
'link' => $appUrl ,
'caption' => 'Test Caption',
'description' => $message,
'attachment' => $media
);
Feed is getting published, but properties are not coming.
Please suggest me to how I should set the properties.
Tested with Graph API Explorer:
POST /me/feed
properties {"name" : {"text":"abc", "href":"http://www.google.com"}, "value" : {"text":"cde", "href":"http://www.google.com"}}
and etc filed.
This works fine for me.
You will need just to json_encode() your properties array, don't need to urldecode() it.
Just this code:
$attachment = array('properties' => json_encode($properties));
I hope i helped.
First urldecode every link you include in the attachment and also json_encode the properties before setting it in the attachment.
$properties = array("Title" => array('text' => "Some Text", 'href' => urldecode($link)));
$attachment = array ('properties' => json_encode($properties))
精彩评论