Noel Tock
Noel Tock

Reputation: 609

Requesting Picture for Event

I've been trying to grab event pictures for a few days now, with no luck. I'm making a normal request just like all the other event elements:

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

Here's a non-functioning example (in explorer): https://developers.facebook.com/tools/explorer/?method=GET&path=107798885938238%2Fpicture

However parent, attending, declined, all work..

Thank you!

Upvotes: 0

Views: 578

Answers (1)

Frederic Blockeel
Frederic Blockeel

Reputation: 24

I've had the same problem as you have.

After some looking into it, I found the solution.

Use http://graph.facebook.com/eventid/?fields=picture&type=large

You can choose small, normal, large or square as type.

You can call this as a separate api call,

$event = $facebook->api('/'.$event['id']);

$picture = $facebook->api('/'.$event['id'].'?fields=picture&type=large');
$picture = $picture['picture'];

echo '<img src="'.$picture.'">';
echo $event['name'];

echo $event['end_time']; // will work, no need to call

or call for other fields at the same time. But then you'll have to define every field you want to call.

$event = $facebook->api('/'.$event['id'].'?fields=name,start_time,picture&type=large');

echo '<img src="'.$event['picture'].'">';
echo $event['name'];

echo $event['end_time']; // will not work, end_time hasn't been called

Upvotes: 1

Related Questions