在转到另一台服务器后,无法通过图形API获取用户名 [英] Unable to retrieve user name through graph api after shifting to another server
问题描述
try {
$ userId = $ _POST [user_id];
$ oauth_token = $ _POST [oauth_token];
$ userName = json_decode(file_get_contents('https://graph.facebook.com/'。$ userId)) - >名称;
$ userGender = json_decode(file_get_contents('http://graph.facebook.com/'。$ userId)) - >性别;
$ userPpicture = json_decode(file_get_contents('http://graph.facebook.com/'。$ userId)) - >图片;
} catch(异常$ e){
echo $ e - >的getMessage();
echo< br>;
}
只是为了添加,这可能有助于在下一行我可以成功通过以下方式查看用户个人资料图片:
< img class = \ppicture\src = \https: //graph.facebook.com/。 $ userId。 ?/画面类型= large\ >
除了这段代码不起作用,照片发布功能刚刚停止工作。
请帮助我。
thankyou。
p>在咨询phpfog支持后,我知道他们的共享托管计划不支持
函数 file_get_contents
。
任何人的专用计划都将能够运行在共享服务上受限制的命令。
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.
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.
这篇关于在转到另一台服务器后,无法通过图形API获取用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!