Unable to get User Profile Picture With Facebook graph api

ぐ巨炮叔叔 提交于 2019-12-23 04:56:27

问题


my angular 2 app uses facebook login to get username, email and profile picture. I am able to get username and email But url for profile picture provided by facebook api does not work.

Here is the flow of the app

  1. user logs in to facebook from my app with permission to name,email and profile picture
  2. After login the app requests for name,email and profile picture using Facebook api
  3. app gets response from facebook api containing all the requested data example below

response : { email:"user@mail.com" id:"992219737612453" name:"user name" picture: { data:height:50 is_silhouette:false url:"https://lookaside.facebook.com/platform/profilepic/? asid=992219737612453&height=50&width=50&ext=1527274398 &hash=AeQwwpehQqNhgVxr" width:50 } }

But the problem is that url given in the above response for picture does not work and gives error 429. But the same url starts working when it is accessed using vpn. Anyone please figure out what the problem is and how to solve it. Note: 429 error stands for too many requests but at facebook developer dashboard page for this app it says your app has not reached level for rate limiting.

UPDATE: URL is being blocked when it is accessed using specific ISP that belongs to CHINA. But the problem is my most users use that Internet service provider.


回答1:


As described in question its a problem of Internet service provider which works/origin is from CHINA. So, you will need neutral ISP from any region or the of the region on which url works.

The only solution to this problem is that you should setup a server (express best option for angular 2/4 ) hosted on different ISP. And the server gets image from that url and returns it back to the client.

Wrong Architecture:

Client ==================================================> Server containing Image

Client <===============429Error(Due to Different ISP)<=========== Server containing Image

Right Architecture:

Angular ===================> Express ==========> Server Containing Image

Angular <=================== Express <========== Server Containing Image




回答2:


If this is working over a VPN, it sounds like a permissions issue. What permissions could the VPN allow that the local machine or server you are running from does not have?



来源:https://stackoverflow.com/questions/50475104/unable-to-get-user-profile-picture-with-facebook-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!