0

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

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>";
            }

只是补充一下,因为这可能有助于在下一行中,我可以通过以下方式成功检索用户个人资料图片:

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

除了这段代码不起作用之外,照片发布功能也刚刚停止工作。请帮我解决这个问题。

谢谢你。

4

2 回答 2

0

直接检索用户照片 (/[user id]/picture) 的能力不需要令牌,因此这不是有效的测试。

如果您保存了 oauth 令牌,您可能需要使用新的应用程序地址列表重新启动用户会话。要确认,您应该在此处将您正在使用的令牌复制到 FB 的调试界面:

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

希望有帮助。

于 2012-03-19T22:04:21.827 回答
0

在咨询了 phpfog 支持后,我知道他们的共享主机计划不支持该功能file_get_contents

他们的任何专用计划都将能够运行受限于其共享服务的命令。

于 2012-03-23T22:31:39.957 回答