简体   繁体   English

PHP Facebook SDK - 如何将朋友个人资料图片发布到墙上?

[英]PHP Facebook SDK - how to post friends profile picture to the wall?

I am trying 我在尝试

$attachment = array('message' => "message",
            'name' => 'name',
            'caption' => "caption",
            'link' => 'some URL address',
            'picture' => "https://graph.facebook.com/PROFILE_ID_NUMBER/picture");

But the post on the wall is not posted. 但是墙上的帖子没有张贴。 When I pick some other image and set up the URL, it works well. 当我选择其他图像并设置URL时,它运行良好。 This https://graph.facebook.com/PROFILE_ID_NUMBER/picture returns me user's profile picture in the application without any problems, but when I am trying to post it to the wall, then it doesn't work. 这个https://graph.facebook.com/PROFILE_ID_NUMBER/picture在应用程序中返回用户的个人资料图片没有任何问题,但是当我试图将其发布到墙上时,它不起作用。

So - how could I get the URL of the user's profile picture and post it to the wall? 那么 - 我怎样才能获得用户个人资料图片的网址并将其发布到墙上?

https://graph.facebook.com/PROFILE_ID_NUMBER/picture 

redirects to original image url, which you can get using get_headers function of PHP. 重定向到原始图像url,您可以使用PHP的get_headers函数获取。 something like this you can do: 你可以这样做:

$headers = get_headers("https://graph.facebook.com/$fbid/picture?type=large");
$image_loc = $headers[5]; //if not work, check at what index actual url is coming though it works for me

and then use this $image_loc url for posting on facebook. 然后使用此$ image_loc网址在Facebook上发布。

Strange, but 奇怪,但是

'picture' => "https://graph.facebook.com/PROFILE_ID_NUMBER/picture"); 'picture'=>“https://graph.facebook.com/PROFILE_ID_NUMBER/picture”);

should show the PROFILE_ID's pic in the post... I tried and got that, in fact it shows the pic of any user, not necessarily my friend :) 应该在帖子中显示PROFILE_ID的图片...我试过并得到了它,实际上它显示了任何用户的图片,不一定是我的朋友:)

Try using the user's access token with the picture link, might work .. 尝试使用用户的访问令牌与图片链接,可能会工作..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM