Facebook API: upload photos to a group

I want to upload a photo to one of the user groups. Is it possible?

If this is not possible, is there any work for this?

Regards, Sanket

+3
source share
1 answer

Facebook has decent documentation about uploading to a group. You can send an image object to an API group

https://developers.facebook.com/docs/reference/api/group/

Be sure to read the link above and read the CREATE section, as well as any necessary permissions, etc. You are using code with the latest php-sdk, should look something like this ...

//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'];
}
}

An important part:

$data = $facebook->api('/me/photos', 'post', $args);

which is loaded by the user, you can change this to send something like this to the group ...

$data = $facebook->api('/GROUP_ID/photos', 'post', $args);
+4
source

All Articles