Facebook 发布流
我有问题...我确实关注了 此网站...我不擅长 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 />";
}
?>
我收到错误:
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}
i have problem... I did follow this site... Im not good at facebook API.. sorry im really noobs with API..
my code:
<?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}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到答案:
这里解决方案:
http://www.facebook.com/connect/prompt_permissions.php?api_key=YOUR_API_KEY&v=1.0&next=http://www .facebook.com/connect/login_suc cess.html?xxRESULTTOKENxx&display=page&ext_perm=publish_stream,offline_access&enable_profile_selector=1&profile_selector_ids=ID_OF_YOUR_PAGE
以粗体文本插入您的 API 密钥和页面 ID。
I found answer:
here solution:
http://www.facebook.com/connect/prompt_permissions.php?api_key=YOUR_API_KEY&v=1.0&next=http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&display=page&ext_perm=publish_stream,offline_access&enable_profile_selector=1&profile_selector_ids=ID_OF_YOUR_PAGE
Insert your API Key and Page ID in BOLD text..