更新时间:2023-12-02 18:24:46
使用Graph API将图片上传到现有的相册(或创建一个新的相册)。
将看起来像这样:
$ args = array('message'= &'Caption');
$ args ['image'] ='@'。真实路径( the_image.png);
尝试{
$ data = $ facebook-> api('/'.$ album_uid。'/ photos','post',$ args);
}
catch(异常$ e){
print< pre>;
print_r($ e);
print< / pre>;
}
然后通过Graph API获取上传的图片,并重定向到图片的链接,将& makeprofile = 1
添加到querystring中。用户现在将被重定向到配置文件图像裁剪页面:
try {
$ pictue = $ facebook-> api('/'.$ data ['id']);
header(Location:。$ pictue ['link']。& makeprofile = 1);
}
catch(异常$ e){
print< pre>;
print_r($ e);
print< / pre>;
}
Is there any way to change the user's profile picture using the graph api?
I know you can't with the rest api (reference), but I could not find anything in the new graph api.
Upload the picture to an existing album (or create a new one) using the Graph API. Will look something like this:
$args = array('message' => 'Caption');
$args['image'] = '@' . realpath("the_image.png");
try {
$data = $facebook->api('/'.$album_uid.'/photos', 'post', $args);
}
catch(Exception $e) {
print "<pre>";
print_r($e);
print "</pre>";
}
Then get the uploaded image via the Graph API and redirect to the image's link, add &makeprofile=1
to the querystring. The user will now be redirected to the profile image cropping page:
try {
$pictue = $facebook->api('/'.$data['id']);
header("Location: ".$pictue['link']."&makeprofile=1");
}
catch(Exception $e) {
print "<pre>";
print_r($e);
print "</pre>";
}