2012-01-26 20 views
1

早上好友, 我遇到了facebook api问题: 是否可以从外部来源上传照片?例如,指出的URL和Facebook将获得的是...... 我的代码是旁边

$args = array( 'message' => 'Photo from application', 'source' => $im_url );
$url = 'https://graph.facebook.com/'.$album_id.'/photos?access_token='.$token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);

的$ im_url应该指出来一个外部图片,比如在imageshack上的商店等。
它给我的错误是{"error":{"message":"(#324) Requires upload file","type":"OAuthException"}}

Php Facebook - 从外部来源上传图片

回答

4

而不是“来源”,术语是“url”。问题解决了 $args = array( 'message' => 'Photo from application', 'url' => $im_url

+0

好找!快乐的编码! – DMCS

+0

谢谢你。我之前正在查看文档,无法找到它。我猜你的眼睛更锐利! - “Fields”表格中仍缺少它,但它看起来像是匆匆添加到主要描述的最后: “您也可以通过提供带有照片URL的url参数来发布照片。” http://developers.facebook.com/docs/reference/api/photo/ – ozmo