[英]Facebook API: Uploading photo in a group
I want to upload photo to one of the user's groups. 我想将照片上传到其中一个用户组。 Is it possible?
可能吗?
If it's not possible then is there any work-around for this? 如果不可能那么有没有解决方法呢?
Regards, Sanket 此致,Sanket
Facebook has decent documentation about uploading to a group. Facebook有关于上传到群组的文档。 You can post a picture object to the group API
您可以将图片对象发布到组API
https://developers.facebook.com/docs/reference/api/group/
Make sure to read the above link and read the CREATE section, also any needed permissions, etc. You code using the latest php-sdk should look similar to this... 请务必阅读上面的链接并阅读CREATE部分,以及任何所需的权限等。您使用最新的php-sdk代码看起来应该与此类似...
//IF FILE UPLOAD
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 2000000)){
if ($_FILES["file"]["error"] > 0){
$error .= "Return Code: " . $_FILES["file"]["error"] . "<br />";
}else{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
$args = array('message' => $_GET['title']);
$args['image'] = '@' . realpath($_FILES["file"]["tmp_name"]);
$data = $facebook->api('/me/photos', 'post', $args);
$entry->details = $data['id'];
}
}
The important part is: 重要的是:
$data = $facebook->api('/me/photos', 'post', $args);
which uploads to the user, you can change this to post to a group something like this... 上传到用户,你可以改变这个发布到这样的组...
$data = $facebook->api('/GROUP_ID/photos', 'post', $args);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.