Facebook应用程序:如何发布wallpost

时间:2012-03-05 13:15:13

标签: php facebook sdk

我暂时没有使用FBML和PHP SDK,我只能再获得wallpost了吗?去年我的代码工作正常,但现在它不会工作...所以我的应用程序如何再次贴墙?帮助:)

旧代码:

    <?php

  require_once('fb/src/facebook.php');

  $config = array(
    'appId' => '******',
    'secret' => '***********',
  );

  $facebook = new Facebook($config);
  $user_id = $facebook->getUser();



$tiedosto = file("http://mydomain.com/doh.txt");

$sids = $tiedosto[$total];

$tiditii = "What's here:";
$message = "";
$text = "Checkout!";

 $attachment = array('name' => "$tiditii", 'href' => 'http://mydomain.com/do',
 'description' => "$sids
  ", 'media' => array(array('type' => 'image', 'src' => 'http://mydomain.com/pic.gif',
 'href' => 'http://mydomain.com/do')));
?>
<script>
function callback_function(){document.setLocation("http://apps.facebook.com/myapp");};
function publishPost() {
        var msg = <?= json_encode($message) ?>;
        var attachment = <?= json_encode($attachment) ?>;
        Facebook.streamPublish(msg, attachment);
}
</script><p>
<input name="Next" type="button" id="button" class="appMY_APP_ID_button" value="Publish" onclick="publishPost(); return false;"/>

2 个答案:

答案 0 :(得分:1)

使用图API

尝试这样的事情
   $attachment =  array(
            'access_token' => $access_token,
            'message' => "Hello, here is a post",
            'name' => "",
            'link' => "http://www......",
            'description' => "Write here your description",
            'picture'=> "http://www.yourserver.com/images/test.jpg";
            );
        //print_r($attachment);
        $facebook->api('/me/feed', 'POST', $attachment);

可以找到Facebook PHP SDK here

答案 1 :(得分:0)

我对php不太了解..但为什么不使用FB的java脚本sdk。它易于使用。 https://developers.facebook.com/docs/reference/javascript/