Fb.Connect.StreamPublish with images: type 'i' is not allowed
Any ideas on what that error means? I have an attachment media type image with a ful开发者_StackOverflow社区l URL specified and I am seeing this error.
I know that this is old post but if someone need solution then it is to wrap media in brackets [] like this:
{"media": [
{
"type": "image",
"src": "http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-kitten-finished-his-milk-and-wants-a-cookie.jpg",
"href": "http://icanhascheezburger.com/2009/03/30/funny-pictures-awlll-gone-cookie-now/"
},
{
"type": "image",
"src": "http://photos.icanhascheezburger.com/completestore/2009/1/18/128768048603560273.jpg",
"href": "http://ihasahotdog.com/upcoming/?pid=20869"
}]
}
Because it is array of media...
You can find more info here: http://developers.facebook.com/docs/guides/attachments/ and here http://developers.facebook.com/docs/reference/rest/stream.publish/
j.
If you're using PHP's json_encode to translate from php to json, the media item has to be a json array not a json object. See http://php.net/manual/en/function.json-encode.php for object/array differences.
Works:
$media = array(
'media' => array(
array(
'type' => "image",
'src' => file_create_url($image->uri),
'href' => url('node/' . $node->nid, array('absolute' => TRUE)),
),
),
);
return json_encode($media);
Doesn't Work:
$media = array(
'media' => array(
'type' => "image",
'src' => file_create_url($image->uri),
'href' => url('node/' . $node->nid, array('absolute' => TRUE)),
),
);
return json_encode($media);
精彩评论