Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get events from a page "Unable to convert response from Graph to a GraphNode" #73

Closed
BriBarthelemy opened this issue Jun 9, 2015 · 7 comments

Comments

@BriBarthelemy
Copy link

Hello,
I have an issue to covert events from page-id:

$fb = App::make('SammyK\LaravelFacebookSdk\LaravelFacebookSdk');
$fb->setDefaultAccessToken('token-string-xxx');

// Get basic info on the user from Facebook.
try {
    $response = $fb->get('/{page-id}/events');

} catch (Facebook\Exceptions\FacebookSDKException $e) {
    dd($e->getMessage());
}
//$response = $request->execute();
$graphObject = $response->getGraphObject();

Always same answer :
FacebookSDKException in GraphNodeFactory.php line 224:
Unable to convert response from Graph to a GraphNode because the response looks like a GraphEdge. Try using GraphNodeFactory::makeGraphEdge() instead.

I've try as you see here : https://developers.facebook.com/docs/graph-api/reference/page/events/

Do I do it wrong?
Thanks for your help.

@SammyK
Copy link
Owner

SammyK commented Jun 10, 2015

Do I do it wrong?

Yes. :) But you're really close!

The /{page-id}/events endpoint is an edge and returns multiple Event nodes. So you can't use getGraphObject() on the response since that method tries to convert the response into a single Graph node collection. You have to use getGraphList() (which is now getGraphEdge()).

So just change this:

$graphObject = $response->getGraphObject();

To this:

// If you have an old dev version of the official SDK
$graphEdge = $response->getGraphList();
// Or if you have the latest dev version of the official SDK
$graphEdge = $response->getGraphEdge();

@SammyK SammyK closed this as completed Jun 10, 2015
@upwebdesign
Copy link

One question I have about this is how do you request more pages after you get the first 10 results?

@upwebdesign
Copy link

I assume it is something similar to this, but I always get null. Here is what I suspect we do for paging:

$response = $response->getGraphEdge();
$response = $this->fb->previous($response); OR
$response = $this->fb->next($response);

Am I on track with this? It may be that I just dont have enough results for paging. Im not sure what the default limit is.

@SammyK
Copy link
Owner

SammyK commented Jun 11, 2015

@upwebdesign Yes, you would pass the results from getGraphEdge() to next() and previous(). If it returns null, that means there are no more results.

@seetozenith
Copy link

I wrote below these code:::
$request = new Facebook\FacebookRequest(
$session,
'GET',
'/'.$user_id.'/friends'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();

Error:: Fatal error: Call to undefined method Facebook\FacebookRequest::execute()

Any suggestion please..............

@jaketoolson
Copy link

@seetozenith you are calling the facebook SDK directly... why aren't you calling the GET request using this package's SDK wrapper?

@themood54
Copy link

your not doing it wrong, all the code on facebook is missing parts for the .php the only one that works from the facebook dev is javascript and even that is missing parts they must have done it on purpose so only true developers would be able to get it going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants