Facebook PHP SDK 3 won't work on 32-bit system, facebook ids treated as int and can be > 2147483647, best solution?
I'm using facebooks PHP SDK version 3. It turns out that it won't work on 32-bit system as the SDK casts the facebook ids to integers and the ids can be larger than 2147483647 that is a 32-bit systems max integer value.
I also found the issue here https://github.com/facebook/php-sdk/issues/11
Is there anyone that has a "not so hacky" sol开发者_如何学编程ution for this?
There is a workaround for this. Just change integer to string
Find this line
$user = $signed_request['user_id'];
and change it to
$user = (string) $signed_request['user_id'];
and also find
$user = $this->getUserFromAccessToken();
and change it to
$user = (string) $this->getUserFromAccessToken();
and also find
$user = $this->getPersistentData('user_id', $default = 0);
change it to
$user = (string) $this->getPersistentData('user_id', $default = 0);
And it works. Int isn't able to handle such a long user ids on 32bit systems, that's why is it making problems
Until Facebook come up with a fix, I'd suggest you use one of the solutions in the comments.
Converting the number into a string is the only way to resolve your issue for these types of numbers on a 32 bit system.
精彩评论