简体   繁体   English

使用php SDK时,getUser()返回0。 几天前它在工作,代码未更改

[英]getUser() returning 0 when using php SDK. It was working a few days ago and the code has not changed

I'm using the php SDK getUser() function to receive a facebook user's ID, but now it's returning 0 when a few days ago it was returning the correct ID. 我正在使用php SDK的getUser()函数来接收Facebook用户的ID,但是几天前它返回正确的ID时,它现在返回0。 Has something changed? 有什么改变吗? Any reason why it would stop working all of a sudden? 它为什么会突然停止工作,是什么原因?

Of course you need an access token for getting the user id. 当然,您需要访问令牌才能获取用户ID。 Just authorize your user (again) with "getLoginUrl": https://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/ 再次使用“ getLoginUrl”授权您的用户: https : //developers.facebook.com/docs/reference/php/facebook-getLoginUrl/

Be aware that a user access token is valid for 2 hours only (or 60 days if you extend it with "setExtendedAccessToken"). 请注意,用户访问令牌仅在2个小时内有效(如果使用“ setExtendedAccessToken”进行扩展,则有效期为60天)。

If it doesn´t work even after authorizing the user with getLoginUrl, keep in mind that you have to call that url again to refresh the access token. 如果使用getLoginUrl授权用户后仍然无法使用,请记住,您必须再次调用该URL来刷新访问令牌。 Also, make sure your PHP SDK is up to date and the settings are correct (App-ID and App-Secret). 另外,请确保您的PHP SDK是最新的并且设置正确(App-ID和App-Secret)。

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

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