I have the following PHP code to post in a Facebook Group Feed where the the publisher is admin of. The code is as follows:
$post_array=array ('link'=>$link_share,'message' => $message);
try {
$response = $fb->post(
"/{$group_id}" . "/feed",
$post_array,
"{$access_token}"
);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
But when I execute it I get the error:
Graph returned an error: Unsupported post request. Object with ID 'group_id' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api
I read all the documentation, the user has the permissions to publish in the group but I keep getting that error. Any ideas why?
Thanks
Related
someone please help me. i'm trying to post a picture to the group but it's not working. Posts still appear on the group but no photos.
My code
$post_data = array(
'caption' => $mess,
'url' => $urlphoto
);
try {
$response = $fb->post('/944379269276566/photos', $post_data, $pageAccessToken);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: '.$e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: '.$e->getMessage();
exit;
}
this error occurs when you include a question mark (?) in the caption.
and this is a Facebook bug
https://developers.facebook.com/support/bugs/739380653703276/
Following at the Facebook API docs I'm able to return only 4 attributes from my FB app.
My Code:
$user = Auth::user();
try {
$response = $this->facebook->get('/'.$user->facebook_app_id, $user->facebook_access_token);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
dd($graphNode);
This only returns 4 attributes
I need it to also return app_domains. Looking at the docs it looks like it should? Is there a way to return the app_domains array from a FB app? FB app API
Looks like you'll need to use something like this:
$response = $this->facebook->get('/'.$user->facebook_app_id,
['fields' => 'app_domains'],
$user->facebook_access_token
);
https://www.facebook.com/profile.php?id=100010558444183
I want to get this profile id when user login with Facebook.
I tried with this but it gives something else.
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->get('/me',$access_token);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$user = $response->getGraphUser();
$id = $user['id']; ```
You cannot get the "real" id anymore, only an App Scoped ID that is unique and can still be used for identifying returning users. If you want to get a link to the user profile, use the link field: https://developers.facebook.com/docs/graph-api/reference/v3.2/user
For example:
$response = $fb->get('/me?fields=name,link', $access_token);
More details: https://github.com/facebook/php-graph-sdk/blob/5.x/docs/examples/retrieve_user_profile.md
I'm learning how to create a web app to manage my group using Facebook PHP SDK v5.0. When I delete my group members, system throw an exception:
Exception 'Facebook\Exceptions\FacebookResponseException' with message
'(#3) Unknown method'.
This is my code
public function removeMemberByMemberId($group_id, $memberid, $fb, $access_token){
try {
$request = $fb->delete('/'.$group_id .'/members', ['members' => "'" . $memberid . "'"], $access_token);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
}
Please help me!
Thank you so much!
I have code for uploading image using SDK v4 to post on fb timeline
$linkData = [
// 'link' => 'http://www.example.com',
'message' => 'User provided message',
'source' => $fb->fileToUpload('/img/about_two.jpg'),
];
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->post('/me/photos', $linkData, 'XXXXXXXXXXX');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
I got error msg 'Graph returned an error: (#100) source is not properly formatted'. I tried with live link for the image path,set image size to 200 X 00. But again shows same error.
Anyone can help.
Thanks