上傳圖像後,我試圖標記圖像,但上傳圖像後返回的「id」顯然沒有用處。Facebook使用Graph/REST API上傳後的標記圖像
我想知道是否有人能夠實現相同?
function upload_image($file,$session,$message) {
$args = array(
'message' => $message,
);
$args[basename($file)] = '@' . realpath($file);
$ch = curl_init();
$url = 'https://graph.facebook.com/'.$album_id.'/photos?access_token='.$session['access_token'];
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);
$result = json_decode($data,true);
$picture = $result['id'];
print_r($picture);
$json = 'https://api.facebook.com/method/photos.addTag?pid='.$picture.'&tag_text=Test&x=0&y=0&access_token='.$session['access_token'];
$ch = curl_init();
$url = $json;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
$data = curl_exec($ch);
print_r($data);
}
輝煌的答覆。如果我可以多次讚揚這一點,我會。我會檢查一切,並嘗試一次,讓你知道。我唯一擔心的是舊的API很快就會被棄用。 – 2010-12-14 09:21:03
完美的作品。謝謝。 – 2010-12-14 13:24:05