Facebook Graph API,扩展权限
我正在尝试使用 facebook Graph API 来更新用户状态消息。
我在使用它时收到以下错误,我认为新的 graph sdk 没有被正确引用?
Notice: Undefined property: Facebook::$api_client in /users/home/aafhe7vh/web/public/update.php on line 9
Fatal error: Call to a member function users_hasAppPermission() on a non-object in /users/home/aafhe7vh/web/public/update.php on line 9
这是我正在使用的文件 http://github.com /facebook/php-sdk/blob/master/src/facebook.php
以下是我的 update.php 的内容:
# <?php
include_once ('facebook.php');
$api_key = '@@@@@@@@@@@@@@@@@@@2';
$secret = '$$$$$$$$$$$$$$$$$$$$44';
global $facebook;
$facebook = new Facebook($api_key, $secret);
# include_once("config.php");
# if (!$facebook->api_client->users_hasAppPermission("status_update")){
# echo '<fb:prompt-permission perms="status_update" next_fbjs="greet()">Let us update your status </fb:prompt-permission>';
# $visibility = "none";
# }
# else
# $visibility = "block";
#
# if(isset($_POST['hello']))
# {
# $facebook->api_client->users_setStatus($_POST['hello']);
# echo "<p>Your status has been updated</p>";
# }
# ?>
# <div id="statusdiv" style="display:<?=$visibility;?>;">
# <form method="POST">
# Please update your status:<br/>
# <input type="text" name="status" /> <br/>
# <input type="submit" value="change status" />
# </form>
# </div>
#
# <script>
#
function greet()
# {
# var session = "<?=$facebook->api_client->session_key;?>";
# document.getElementById("statusdiv").setStyle("display","block");
# new Dialog().showMessage("Info","Thank you for granting us this permission! ");
# }
</script>
我使用了这里的上述代码,http://fbcookbook.ofhas.in/tag/extended-permission/
我不确定 config.php 应该包含什么,所以我已删除我的代码中的该行。
谢谢。
I am trying to use facebook Graph API, to update a users staus message.
I am getting the following error while using it, I think the new graph sdk is not being properly referenced ?
Notice: Undefined property: Facebook::$api_client in /users/home/aafhe7vh/web/public/update.php on line 9
Fatal error: Call to a member function users_hasAppPermission() on a non-object in /users/home/aafhe7vh/web/public/update.php on line 9
This is the file I am using http://github.com/facebook/php-sdk/blob/master/src/facebook.php
Following is the content of my update.php:
# <?php
include_once ('facebook.php');
$api_key = '@@@@@@@@@@@@@@@@@@@2';
$secret = '$$$$$$$$$$44';
global $facebook;
$facebook = new Facebook($api_key, $secret);
# include_once("config.php");
# if (!$facebook->api_client->users_hasAppPermission("status_update")){
# echo '<fb:prompt-permission perms="status_update" next_fbjs="greet()">Let us update your status </fb:prompt-permission>';
# $visibility = "none";
# }
# else
# $visibility = "block";
#
# if(isset($_POST['hello']))
# {
# $facebook->api_client->users_setStatus($_POST['hello']);
# echo "<p>Your status has been updated</p>";
# }
# ?>
# <div id="statusdiv" style="display:<?=$visibility;?>;">
# <form method="POST">
# Please update your status:<br/>
# <input type="text" name="status" /> <br/>
# <input type="submit" value="change status" />
# </form>
# </div>
#
# <script>
#
function greet()
# {
# var session = "<?=$facebook->api_client->session_key;?>";
# document.getElementById("statusdiv").setStyle("display","block");
# new Dialog().showMessage("Info","Thank you for granting us this permission! ");
# }
</script>
I used the above code from here , http://fbcookbook.ofhas.in/tag/extended-permission/
I am not sure what the config.php should contain so I have removed that line in my code.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您包含最新的 PHP SDK,但您的代码是为旧 SDK 编写的。因此,要么降级到以前版本的 SDK,要么更改您的实现。
有关参数的更多详细信息,请参阅相应文档。
编辑
对您的问题的答复
1] 使用新的 SDK 时 - 一切都不同了。你必须像这样创建对象
2] 修复我上面的代码
3] http://developers .facebook.com/docs/reference/api/
You're including newest PHP SDK but your code is written for the old SDK. So, either downgrade to the previous version of the SDK, or change your implementation.
See the corresponding documentation for more details about the parameters.
EDIT
A response to your questions
1] When using the new SDK - everything is different. You have to create the object like this
2] Fixed my code above
3] http://developers.facebook.com/docs/reference/api/
使用 Graph API,当用户允许您的应用程序时,您必须说“我需要 status_update”。
With the Graph API, when the user allows your application, you must say that "I need status_update".