Question

someone knowS how to get a profile picture from Json data,I get all information(usernam,firstname,FacebookId) but I can't have the link of picture of my profile :

namespace djepo\UserBundle\Security\User\Provider;

use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use \BaseFacebook;
use \FacebookApiException;

class FacebookProvider implements UserProviderInterface
{
/**
 * @var \Facebook
 */
protected $facebook;
protected $userManager;
protected $validator;
....
....
public function loadUserByUsername($username)
{           
    $user = $this->findUserByFbId($username);


    try {
        $fbdata = $this->facebook->api('/me');// Here I Get all information without pic
    } catch (FacebookApiException $e) {
        $fbdata = null;
    }

    if (!empty($fbdata)) {     
        var_dump($fbdata);// here I see object with result of data
        exit();
        $user_by_mail=$this->userManager->findUserBy(array('email'=>$fbdata['email']));

      .....
       ....
Was it helpful?

Solution

If you have their username, all you need to do is curl the following:

http://graph.facebook.com/username/picture

You may need to allow redirection in your curlopt settings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top