facebook publish stream



我有问题…我确实关注了这个网站…我不擅长facebook的API…对不起,我对API真是一窍不通。

我代码:

<?php

define('FB_APIKEY', '***************************');
define('FB_SECRET', '***************************');
define('FB_SESSION', '***************************');
require_once 'facebook-platform/php/facebook.php';
echo "post on wall";
echo "<br/>";
try {
 $facebook = new Facebook(FB_APIKEY, FB_SECRET);
 $facebook->api_client->session_key = FB_SESSION;
 $facebook->api_client->expires = 0;
 $message = 'testasdfsadf';
 $attachment = array(
 'name' => $_POST["name"],
 'href' => $_POST["href"],
 'description' => $_POST["description"],
 'media' => array(array('type' => 'image',
 'src' => $_POST["src"],
 'href' => $_POST["href"])));
 $action_links = array( array('text' => 'TITLE', 'href' => 'http://www.mysite.com'));
 $attachment = json_encode($attachment);
 $action_links = json_encode($action_links);
 $target_id = "2410160********";
 $session_key = FB_SESSION;

     if( $facebook->api_client->stream_publish($message, $attachment, $action_links, null, $target_id)) {
     echo "Added on FB Wall";
     }
     } catch(Exception $e) {
     echo $e . "<br />";
     }
?>

I got error:

post on wall
exception 'FacebookRestClientException' with message 'The user hasn't authorized the application to perform this action' in /Users/*****/Sites/FacebookTEST/facebook-platform/php/facebookapi_php5_restlib.php:3025 Stack trace: #0 /Users/******/Sites/FacebookTEST/facebook-platform/php/facebookapi_php5_restlib.php(916): FacebookRestClient->call_method('facebook.stream...', Array) #1 /Users/******/Sites/FacebookTEST/index.php(46): FacebookRestClient->stream_publish('testasdfsadf', '{"name":null,"h...', '[{"text":"TITLE...', NULL, '2410160********') #2 {main}

我找到了答案:

以下解决方案:http://www.facebook.com/connect/prompt_permissions.php?api_key= YOUR_API_KEY , v = 1.0,接下来= http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&显示= page& ext_perm = publish_stream offline_access& enable_profile_selector = 1, profile_selector_ids = ID_OF_YOUR_PAGE

最新更新