使用Facebook SDK for PHP发布操作时出现问题

时间:2012-09-24 01:28:27

标签: php facebook facebook-graph-api facebook-opengraph publishing

我已将以下代码添加到“正文”部分:

<?php
  require "php-sdk/facebook.php";
  $facebook = new Facebook(array(
    'appId'=>'xxxxxxxxx',
    'secret'=>'xxxxxxxxxxxxxxxxx',
    'cookie'=>true
  ));
  if(!$facebook->getUser()) {
    $url = $facebook->getLoginUrl(array('scope'=>'publish_actions'));
    echo "<script> top.location=\"".$url."\"; </script>";
    exit(0);
  }
  $params = array('photo'=>'' . site_url( $this->uri->uri_string() ) . '',
      'access_token'=>$facebook->getAccessToken());
  $out = $facebook->api('/me/marcellusmusic:love','post',$params);
  print_r($out);
?>

我收到以下错误:

Uncaught OAuthException:
  Unknown path components:
    /app_marcellusmusic:love thrown in /home/content/88/4739388/html/php-sdk/base_facebook.php on line 1238'

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

什么是 marcellusmusic:爱

也许你应该像这样使用它:

<?php
  require "php-sdk/facebook.php";
  $facebook = new Facebook(array(
    'appId'=>'xxxxxxxxx',
    'secret'=>'xxxxxxxxxxxxxxxxx',
    'cookie'=>true
  ));
  if(!$facebook->getUser()) {
    $url = $facebook->getLoginUrl(array('scope'=>'publish_actions'));
    echo "<script> top.location=\"".$url."\"; </script>";
    exit(0);
  }
  $params = array('photo'=>'' . site_url( $this->uri->uri_string() ) . '',
      'access_token'=>$facebook->getAccessToken());
  $out = $facebook->api('/me/feed','post',$params);
  print_r($out);
?>

我只改变了api路径。