简体   繁体   English

无法使用Facebook图形API获取用户个人资料图片

[英]Unable to get User Profile Picture With Facebook graph api

my angular 2 app uses facebook login to get username, email and profile picture. 我的angular 2应用使用Facebook登录来获取用户名,电子邮件和个人资料图片。 I am able to get username and email But url for profile picture provided by facebook api does not work. 我能够获取用户名和电子邮件,但是facebook api提供的个人资料图片的网址不起作用。

Here is the flow of the app 这是应用程序的流程

  1. user logs in to facebook from my app with permission to name,email and profile picture 用户从我的应用程序登录到Facebook,并具有名称,电子邮件和个人资料图片的权限
  2. After login the app requests for name,email and profile picture using Facebook api 登录后,应用程序使用Facebook API请求名称,电子邮件和个人资料图片
  3. app gets response from facebook api containing all the requested data example below 应用程序从Facebook api获取响应,其中包含以下所有请求的数据示例

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. 但是问题是上述响应中给图片提供的url不起作用,并显示错误429。但是当使用vpn访问该URL时,相同的url开始起作用。 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. 注意:429错误代表太多请求,但在此应用程序的Facebook开发人员仪表板页面上,它表示您的应用程序未达到速率限制级别。

UPDATE: URL is being blocked when it is accessed using specific ISP that belongs to CHINA. 更新:使用属于中国的特定ISP访问URL时,URL被阻止。 But the problem is my most users use that Internet service provider. 但是问题是我的大多数用户都使用该Internet服务提供商。

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. 因此,您将需要来自URL起作用的任何区域或区域的中性ISP。

The only solution to this problem is that you should setup a server (express best option for angular 2/4 ) hosted on different ISP. 解决此问题的唯一方法是,您应该设置在不同ISP上托管的服务器(为angular 2/4表示最佳选项)。 And the server gets image from that url and returns it back to the client. 然后服务器从该URL获取图像,并将其返回给客户端。

Wrong Architecture: 错误的架构:

Client ==================================================> Server containing Image 客户================================================= =>服务器包含图像

Client <===============429Error(Due to Different ISP)<=========== Server containing Image 客户端<=============== 429错误(由于不同的ISP)<============服务器包含图像

Right Architecture: 正确的架构:

Angular ===================> Express ==========> Server Containing Image 角度===================> Express ===========>服务器包含图像

Angular <=================== Express <========== Server Containing Image 角度<=================== Express <===========服务器包含图像

If this is working over a VPN, it sounds like a permissions issue. 如果这是通过VPN进行的,这听起来像是权限问题。 What permissions could the VPN allow that the local machine or server you are running from does not have? VPN可以允许您从中运行的本地计算机或服务器没有什么权限?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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