从FB应用程序在facebook墙上发布静态消息


Posting a static message on facebook wall from FB application

我有一个facebook应用程序,我想通过从我的flex应用程序调用php脚本从应用程序直接发布消息到墙上。你能帮我一下吗?

function postmessage($appid) {
    $facebook = new Facebook(array(
        'appId' => 'XXX',
        'secret' => 'xxx',
        'cookie' => true
    ));
    $session = $facebook->getSession();
    $attachment = array(
        'message' => 'this is my message',
        'name' => 'This',
        'caption' => 'Caption of the Post',
        'link' => 'apps.facebook.com/tvtreasurehunt/',
        'description' => 'this is a description'
    );
    $result = $facebook->api('/me/feed/', 'post', $attachment);
}

下面的代码在用户墙上创建一个帖子。前提条件:你需要有一个有效的access_token和publish_stream权限。

$context = stream_context_create(array(
  "http" => array(
    "method"    => "POST",
    "content"   => http_build_query(array(
      "access_token"    =>      $access_token,
      "link"            =>      $config["fb_app_url"],
      "name"            =>      "name",
      "description"     =>      "description",
    )),
  ),
));
file_get_contents("https://graph.facebook.com/me/feed", false, $context);

有关详细信息,请参阅官方文档:Post on Facebook Developers.