在转到另一台服务器后,无法通过图形API获取用户名 [英] Unable to retrieve user name through graph api after shifting to another server

查看:99
本文介绍了在转到另一台服务器后,无法通过图形API获取用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过图形api从代码中检索用户名,当我在另一个(godaddy)服务器上托管应用程序时,以下代码正常工作,但最近我将应用程序移动到phpfog,从那时起我面临着这个奇怪的问题。

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆