简体   繁体   中英

How to extract the profile picture of some user from facebook or instagram and upload it to profile page of that user at our website??

I am building a website using backend language as PHP.I am using MySql as database.So in my site we have usual registration system where any user can register him/her self.And then we ask to him to complete his/her profile on his/her profile page.

Okk so on profile page there are so many details about the user(like Date of birth,About his/her self, About his/her education, About his/her gender,Ethnicity,...etc) that we ask to fill. One important attribute of the user profile is his/her profile picture.So user can upload his/her profile picture on his/her profile page. But we want to give user 3 options : 1.He/she can upload picture from own computer/phone 2.He/she can upload picture from own facebook profile 3.He/she can upload picture from own instagram profile

I have implemented the 1st option sucessfully and it is working correctly.But i have no idea about how to implement other 2 choices? I have googled quite about this but i could not able to understand how this can be done ia easy approaching way?

I am not so proficient in PHP , so please help someone. Thanks in advance.

So this is a multi part question with a number of factors, unfortunately I won't be able to give you a sample code you can copy and paste but I can hopefully point you in the direction where based on your configuration you know how to proceed.

The first thing you need to ask yourself is if you want to connect over OAuth so all the user has to do is login to facebook and you can get the content of information you'd like or get the FacebookID from the user (or an automated process if they provide the profile URL) and link directly to the image. You can using the Graph API to get to a users picture using the FacebookID like you can see below.

http://graph.facebook.com/ " + facebookId + "/picture?type=square For instance: http://graph.facebook.com/67563683055/picture?type=square

There are also more sizes besides "square". See the docs .

You need to use OAuth you get the FacebookID of the person unless they provide you the id or url to their page.

As per my understanding you can use the graph API

Graph API

Replace userid_here with id of the user you want to get the photo of.

You can use the PHP's file_get_contents function to read that URL and process the retrieved data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM