Jorgeuos
Jorgeuos

Reputation: 541

Get bigger profile picture with php sdk and Graph Api

This peace of code gives me a 50x50px Facebook profile picture. Obviously I need a larger one. How can I get it?

Was searching around SO and only found answers from 2010-2013

$response = (new FacebookRequest(
    $session,
        'GET', '/me?fields=picture,link'
    )
)->execute();

$object = $response->getGraphObject();
$pic = $object->asArray('picture');
$pic = $pic['picture']->data->url;
echo '<img src="'.$pic.'" alt="..." />';

Following throws errors:

    'GET', '/me?fields=picture{width(300)},link'
    // Syntax error "Expected end of string instead of "("." at character 5: width(300)

Upvotes: 2

Views: 1661

Answers (1)

Jorgeuos
Jorgeuos

Reputation: 541

Poorly documented docs about the profile picture field property syntax (hence the curly brackets in my question), but after some digging and testing this is my solution.

    'GET', '/me?fields=picture.width(300),link'

Upvotes: 15

Related Questions