How to get profile image via authentication using facebook php API

Asked

Viewed 2,772 times

6

I would like to know how to copy an image from a link without extension, IE, I’ve used several methods that work for images with extension, but no extension I can not yet, where I will use to copy the Facebook profile image when people access my system.

Example of image url

I’m using this function in javascript:

FB.api('/me', {fields: 'name,email,picture,gender,age_range,link,locale'}, function(response) {});

Where I get the answer to the url described above. I know you have extension to the image, but putting only the extension to access the image, it presents the following error:

"An error occurred while Processing your request. Reference #50.2f2cfea5.1441047871.5277eeef"

  • 1

    Have you used the Facebook API for this ?

  • This url has the image extension: jpg ...//fbcdn-profile-a.akamaihd.net/hprofile-ak-xft1/v/t1.0-1/p50x50/11096518_845923738813093_6295484000724529473_n.jpg?oh=dcb454d6a58b38a9b5c53c6a77fa77fc&Oe=567D1360&Gda=1449651572_a7afd3bd8fc0ee5da218487c49a7d18c

  • Do it and say the result: ...function(response) {
 console.log(response);
}

1 answer

5

The best way, in this case, is to create an authentication through the Facebook API in PHP. Thus, you will be able to obtain information from the user’s profile and forward it to your website. Your question should be edited.

With this you would get the user’s CURRENT profile photo simply with this(and many other settings):

<img src="https://graph.facebook.com/<?php echo $_SESSION['USERNAME']; ?>/picture">

Source

  • Take a look here: https://developers.facebook.com/docs/plugins?locale=pt_BR

Browser other questions tagged

You are not signed in. Login or sign up in order to post.