如何使用PHP和Open Graph API发布到Facebook粉丝专页的墙壁 [英] How can I post to the wall of a Facebook Fan Page using PHP and Open Graph API

查看:160
本文介绍了如何使用PHP和Open Graph API发布到Facebook粉丝专页的墙壁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例代码是值得赞赏的,我似乎找不到这个在线的任何简单的例子。

解决方案

Facebook PHP-SDK ,很容易实现这一点。



要求:



  1. 页面ID

  2. / ol>

    现在正如我所说,根据您的要求,您可能需要 offline_access manage_pages ,但现在这是最简单的直接做法:



    下载PHP SDK后,在$ code> example.php file:





    结果:



    请注意,这个方法要求您作为页面的管理员。


    Sample code is appreciated, I can't seem to find any simple examples of this online.

    解决方案

    Using the new Facebook PHP-SDK, it's very easy to accomplish this.

    Requirements:

    1. Extended Permissions, depending on your needs
    2. Page ID

    Now as I said, depending on your requirements you may need offline_access, manage_pages, but for now this is the simplest straight forward way of doing this:

    After downloading the PHP SDK, and in the example.php file:

    • Acquire the publish_stream permission:

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

    • After successful authentication, you post to the page wall the same way you do it for normal user profile (and with the same options too, message, picture, link, name, caption, description, source):

      $page_id = '123456789';
      $feed_array = array(
          'message' => "Hello world!"
      );
      $page_post = $facebook->api("/$page_id/feed","post",$feed_array);
      

    Result:

    Please note that this approach requires you being an administrator of the page.

    这篇关于如何使用PHP和Open Graph API发布到Facebook粉丝专页的墙壁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆