0

my problem is when I try to get the pic_square and pic_big from the user connected to my application and I get an empty array. This is the code:

$facebook = new Facebook(array(
        'appId'  => FBAPPID,
        'secret' => FBSECRETNUMBER,
        'cookie' => true,));

$user_info = $facebook->api(array(
        'method'     => 'fql.query',
        'query'     => "SELECT pic_square, pic_big FROM user WHERE uid = me()",
        'callback'    => ''
    ));

During the login process I run the same code and it works, but later when I try to implement a function to synch the user picture with FB pic I get no error and no data. Any idea what is the problem?

Thanks a lot.

1 Answer 1

1

My guess is that later the facebook session doesn't exist so you don't have an access token to call the FQL query.

Anyway, why are you using FQL to get those pictures? You can always get them like this:

http://graph.facebook.com/me/picture?type=large or http://graph.facebook.com/me/picture?type=square

Or you can use the user id to get permanent links to the images:

http://graph.facebook.com/USER_ID_HERE/picture?type=square

Good luck

Sign up to request clarification or add additional context in comments.

3 Comments

Yes, I think there is a problem with the session, is it possible to recover the token? And yes, you are right I should get the pictures as you said, but with that I have a couple of issues: 1.- Using /me/ links I get next error: "error": { "type": "OAuthException", "message": "An active access token must be used to query information about the current user." } 2.- If I use the User Id it works but I need to save the picture and with that link I get redirected to another URL, and that is the URL I need to save the file, how can I get that URL (PHP)? Thanks a lot for your help.
I think it's against the facebook TOS to store the user picture on your server. Generally it's a good idea to respect it, or not overtly abuse it. Why do you even need to store it, why not just use it as a permanent link like this <img src='graph.facebook.com/USER_ID_HERE/picture' />. If you do that, whenever the user updates his profile picture, this will change as well. Anyway, here is how you download the picture: file_put_contents('test.jpg', file_get_contents('graph.facebook.com/USER_ID/picture')); or you can use CURL. Good luck
Thanks, now everything work, by the way I dont keep the images stored, just while the app runs, but I need to do it like this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.