【发布时间】:2010-08-15 10:04:32
【问题描述】:
我编写了这个小脚本,它将一张照片 (images/hand.jpg) 上传到默认应用程序相册中的用户个人资料中(在我调用此脚本的女巫的应用相册中)。
现在我有一个问题。 我想获取刚刚上传的照片的唯一 pid(图片 ID)。 当我尝试回显 $data 时,有一个像这样的 int:
120629757986939
这似乎是创建对象的 fbid:
http://www.facebook.com/photo.php?pid=115842&id=100001197451821&ref=fbx_album&fbid=120629757986939
我需要这个:
.../photo.php?pid=115842&id=100001197451821&ref=fbx_album&fbid=120629757986939
有谁知道如何获得这个值? 感谢你的帮助, 卡米洛
在我用来上传照片的脚本下方:
$uid = $facebook->getUser();
$me = $facebook->api('/me');
$token = $session['access_token'];//here I get the token from the $session array
$album_id = $album[0];
//upload your photo
$file= 'images/hand.jpg';
$args = array(
'message' => 'Photo from application',
);
$args[basename($file)] = '@' . realpath($file);
$ch = curl_init();
$url = 'https://graph.facebook.com/'.$album_id.'/photos?access_token='.$token;
$data = post($url, $referer, $agent, $cookie, $args, 1);
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);
【问题讨论】:
标签: facebook