我如何使用PHP和OpenGraphAPI发布到Facebook粉丝页面的墙上

我如何使用PHP和OpenGraphAPI发布到Facebook粉丝页面的墙上,php,facebook,facebook-graph-api,Php,Facebook,Facebook Graph Api,示例代码非常感谢,我似乎在网上找不到任何简单的示例。在将/me/feed/更改为您的页面id时,我没有尝试……只是检查一下 $attachment = array('message' => 'some meesgae', 'name' => 'This is my demo Facebook application!', 'caption' => "Caption of the Post", 'link' => 'mylin

示例代码非常感谢,我似乎在网上找不到任何简单的示例。

在将/me/feed/更改为您的页面id时,我没有尝试……只是检查一下

$attachment = array('message' => 'some meesgae',
        'name' => 'This is my demo Facebook application!',
        'caption' => "Caption of the Post",
        'link' => 'mylink.com',
        'description' => 'this is a description',
        'actions' => array(array('name' => 'Get Search', 'link' => 'google.com')) );
    $result = $facebook->api('/me/feed?access_token='.$access_token, 'post', $attachment);
使用新的,它很容易做到这一点

要求:

  • ,视乎你的需要而定
  • 页面ID
  • 现在正如我所说,根据您的需求,您可能需要
    脱机访问
    管理页面
    ,但目前这是最简单的直接方法:

    下载PHP SDK后,在
    example.PHP
    文件中:

    • 获取
      发布\u流
      权限:

      <fb:login-button perms="publish_stream"></fb:login-button>  
      
    结果:


    请注意,这种方法要求您是该页面的管理员。

    您从哪里获得
    $access\u token
    ?我最近写了一篇关于这方面的文章。您需要获得扩展的访问权限,并且本质上是作为页面管理员的经过身份验证的用户发布。这是使用Graph API而不是Open Graph。许多人在一个页面上可以有不同的角色,允许哪些角色授予应用程序管理facebook页面的权限。
    $page_id = '123456789';
    $feed_array = array(
        'message' => "Hello world!"
    );
    $page_post = $facebook->api("/$page_id/feed","post",$feed_array);