Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中的Facebook api墙贴_Php_Facebook - Fatal编程技术网

php中的Facebook api墙贴

php中的Facebook api墙贴,php,facebook,Php,Facebook,我试过下面的代码不工作 $attachment = array('message' => 'some meesgae', 'name' => 'This is my demo Facebook application!', 'caption' => "Caption of the Post", 'link' => 'http://mylink.com', 'description' => 'this is a description', 'picture' =>

我试过下面的代码不工作

$attachment = array('message' => 'some meesgae', 'name' => 'This is my demo Facebook application!', 'caption' => "Caption of the Post", 'link' => 'http://mylink.com', 'description' => 'this is a description', 'picture' => 'http://mysite.com/pic.gif', 'actions' => array(array('name' => 'Get Search',     'link' => 'http://www.google.com')) );


$result = $facebook->api('/me/feed/','post',$attachment);
我授予了扩展权限“发布流”


您需要对附件进行JSON编码:

$attachment=json\u encode($attachment)

此外,Graph Api不支持操作链接,仅支持以下参数:

message      The message 
picture      If available, a link to the picture included with this post 
link            The link attached to this post 
name            The name of the link 
caption      The caption of the link (appears beneath the link name) 
description  A description of the link (appears beneath the link caption) 
source        If available, the source link attached to this post (for example, a flash or video file)

关于操作链接,BeRecursive是正确的,但是$facebook api函数为您进行json编码,您还可以发送“cb”,这是一个回调函数。

截至今天,facebook发布了以下内容


获取OAutheException:(#1)发生未知错误错误需要在墙上附加更多图片近5张好友图片抱歉,我不太明白?
message      The message 
picture      If available, a link to the picture included with this post 
link            The link attached to this post 
name            The name of the link 
caption      The caption of the link (appears beneath the link name) 
description  A description of the link (appears beneath the link caption) 
source        If available, the source link attached to this post (for example, a flash or video file)
<?
  // Remember to copy files from the SDK's src/ directory to a
  // directory in your application on the server, such as php-sdk/
  require_once('php-sdk/facebook.php');

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

  $facebook = new Facebook($config);
  $user_id = $facebook->getUser();
?>
<html>
  <head></head>
  <body>

  <?
    if($user_id) {

      // We have a user ID, so probably a logged in user.
      // If not, we'll get an exception, which we handle below.
      try {
        $ret_obj = $facebook->api('/me/feed', 'POST',
                                    array(
                                      'link' => 'www.example.com',
                                      'message' => 'Posting with the PHP SDK!'
                                 ));
        echo '<pre>Post ID: ' . $ret_obj['id'] . '</pre>';

      } catch(FacebookApiException $e) {
        // If the user is logged out, you can have a 
        // user ID even though the access token is invalid.
        // In this case, we'll get an exception, so we'll
        // just ask the user to login again here.
        $login_url = $facebook->getLoginUrl( array(
                       'scope' => 'publish_stream'
                       )); 
        echo 'Please <a href="' . $login_url . '">login.</a>';
        error_log($e->getType());
        error_log($e->getMessage());
      }   
      // Give the user a logout link 
      echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';
    } else {

      // No user, so print a link for the user to login
      // To post to a user's wall, we need publish_stream permission
      // We'll use the current URL as the redirect_uri, so we don't
      // need to specify it here.
      $login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' ) );
      echo 'Please <a href="' . $login_url . '">login.</a>';

    } 

  ?>      

  </body> 
</html>