![](/img/trans.png)
[英]Another method for sharing link on facebook wall using Graph API
[英]Publishing To User's Wall Without Being Online/Logged-in - Facebook Sharing Using Graph API
嗨,我是Facebook共享的新手。 我想讓用戶使用其uid登錄,然后將其存儲以備將來使用
主要目的是在用戶牆上共享鏈接
下次再不顯示Facebook窗口,我想通過Ajax發布到他的牆上。
對此有什么幫助將不勝感激!
編輯
我使用了給出的示例,然后嘗試了curl函數
得到這個錯誤
HTTP/1.1 403 Forbidden
Cache-Control: no-store
Content-Type: text/javascript; charset=UTF-8
Expires: Sat, 01 Jan 2000 00:00:00 GMT
P3P: CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p"
Pragma: no-cache
WWW-Authenticate: OAuth "Facebook Platform" "insufficient_scope" "(#200)
This API call requires a valid app_id."
Set-Cookie: datr=g4JBTb4OsRZxBAztV7iIkpWg; expires=Sat, 26-Jan-2013 14:34:43 GMT;
path=/; domain=.facebook.com; httponly
X-Cnection: close
Date: Thu, 27 Jan 2011 14:34:43 GMT
Content-Length: 93
{"error":{"type":"OAuthException","message":"(#200)
This API call requires a valid app_id."}}
進行編輯以使有人可以找到有用的地方
臉書連接
$facebook_connect = array(
'appId' => 'YOUR APP_ID',
'secret' => 'YOUR SEC KEY',
'access_token'=>"USER'S ACCESS TOKEN",
'cookie' => true
);
發布到用戶牆
$facebook->api("/PROFILE_ID/feed", "post", array(
"message"=>"Hi Friends Join ****",
"name"=>"You're invited to join ****!",
"link"=>"www.****.com",
"description"=>"Great site",
"picture"=>"http://www.****.com/logo.jpg",
"caption"=>"Join *****"
)
我建議您首先學習Facebook Graph API的工作方式。
現在要在不登錄的情況下 (代表他)張貼在用戶的牆上,您需要執行以下操作:
access_token
publish_stream
權限, 無需令牌長壽命的訪問: 使您的應用能夠向用戶流和用戶朋友流發布內容,評論和喜歡的內容。 這是一個超集發布許可,其中還包括publish_actions。 但是,請注意,Facebook建議使用用戶啟動的共享模型。 請閱讀平台政策,以確保您了解如何正確使用此權限。 注意,您不需要使用feed對話框,Requests對話框或Send對話框就可以請求publish_stream權限。
需要許可:
這可以通過多種方式完成:
使用登錄插件 :
<div class="fb-login-button" data-show-faces="true" data-width="200" data-scope="publish_stream" data-max-rows="1"></div>
服務器端登錄 (重定向到OAuth對話框):
https://www.facebook.com/dialog/oauth?
client_id=YOUR_APP_ID
&redirect_uri=YOUR_URL
&scope=publish_stream
&state=SOME_ARBITRARY_BUT_UNIQUE_STRING
PHP-SDK :
$loginUrl = $facebook->getLoginUrl(array("scope"=>"publish_stream"));
JS-SDK通過FB.login方法:
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
FB.logout(function(response) {
console.log('Logged out.');
});
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'publish_stream'});
出版:
$USER_ID = "XXXXXXXX"; // Connected once to your APP and not necessary logged-in at the moment
$args = array(
'message' => 'Hello from app',
'link' => 'http://www.masteringapi.com/',
'caption' => 'Visit MasteringAPI.com For Facebook API Tutorials!'
);
$post_id = $facebook->api("/$USER_ID/feed", "post", $args);
注意:
盡管可以在用戶不在場的情況下進行發布,但請務必記住,Facebook建議用戶啟動共享模型
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.