Facebook Graph API,扩展权限

发布于 2024-09-06 14:27:41 字数 2176 浏览 7 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼泪也成诗 2024-09-13 14:27:42

您包含最新的 PHP SDK,但您的代码是为旧 SDK 编写的。因此,要么降级到以前版本的 SDK,要么更改您的实现。

// Old SDK
$facebook->api_client->users_setStatus($_POST['hello']);  

// New SDK
$facebook->api ( array(
    'method' => 'users.setStatus'
  , 'status' => $_POST['hello']
  , 'uid'    => /* user's facebook id */
) );

有关参数的更多详细信息,请参阅相应文档

编辑

对您的问题的答复

1] 使用新的 SDK 时 - 一切都不同了。你必须像这样创建对象

$facebook   = new Facebook(array(
    'appId'  => 'FB_APP_ID'
  , 'secret' => 'FB_APP_SECRET'
  , 'cookie' => true
));

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.

// Old SDK
$facebook->api_client->users_setStatus($_POST['hello']);  

// New SDK
$facebook->api ( array(
    'method' => 'users.setStatus'
  , 'status' => $_POST['hello']
  , 'uid'    => /* user's facebook id */
) );

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

$facebook   = new Facebook(array(
    'appId'  => 'FB_APP_ID'
  , 'secret' => 'FB_APP_SECRET'
  , 'cookie' => true
));

2] Fixed my code above

3] http://developers.facebook.com/docs/reference/api/

带刺的爱情 2024-09-13 14:27:42

使用 Graph API,当用户允许您的应用程序时,您必须说“我需要 status_update”。

With the Graph API, when the user allows your application, you must say that "I need status_update".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文