我正在尝试使用 facebook Graph API 来更新用户状态消息。
我在使用它时遇到以下错误,我认为新的图形 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 应该包含什么,所以我在我的代码中删除了该行。
谢谢。