在FacebookBundle中获取个人资料图片

时间:2013-01-01 02:38:17

标签: symfony symfony-2.1 fosfacebookbundle

有人知道如何从Json数据中获取个人资料图片,我获取所有信息(usernam,firstname,FacebookId)但我无法获得我的个人资料图片链接:

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']));

      .....
       ....

1 个答案:

答案 0 :(得分:0)

如果您有自己的用户名,那么您需要做的只是卷曲以下内容:

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

您可能需要在curlopt设置中允许重定向。