开发者

Fb.Connect.StreamPublish with images: type 'i' is not allowed

开发者 https://www.devze.com 2022-12-29 04:42 出处:网络
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

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

精彩评论

暂无评论...
验证码 换一张
取 消