Unable to retrieve user name through graph api after shifting to another server

﹥>﹥吖頭↗ 提交于 2019-12-13 03:58:57

问题


I am trying retrieve user name from the code through graph api, the below code was working fine when while I was hosting app on another(godaddy) server but recently I moved the application to phpfog and since then am facing this weird problem.

try {
                $userId = $_POST["user_id"];
                $oauth_token = $_POST["oauth_token"];

                $userName =   json_decode(file_get_contents('https://graph.facebook.com/' . $userId)) -> name;
                $userGender =   json_decode(file_get_contents('http://graph.facebook.com/' . $userId)) -> gender;
                $userPpicture =   json_decode(file_get_contents('http://graph.facebook.com/' . $userId)) -> picture;
            } catch(Exception $e) {
                echo $e -> getMessage();
                echo "<br>";
            }

just to add as this may help that in the very next line i can sucessfully retreive user profile picture through this:

<img class=\"ppicture\" src=\"https://graph.facebook.com/" . $userId . "/picture?type=large\">

Beside this piece of code not working, the photo posting functionality has just also stopped working. kindly help me with this.

thankyou.


回答1:


The ability to retrieve a user's photo directly (/[user id]/picture) doesn't require a token, so that's not a valid test.

If you've saved your oauth tokens you may need to re-init the user session with the new application address list. To confirm, you should copy the token you're using to FB's debug interface here:

https://developers.facebook.com/tools/debug

Hope that helps.




回答2:


After consulting phpfog support i came to know that their shared hosting plan doesnot support the function file_get_contents.

Anyone of their dedicated plans will be able to run the commands which are restricted on their shared service.



来源:https://stackoverflow.com/questions/9776935/unable-to-retrieve-user-name-through-graph-api-after-shifting-to-another-server

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