[英]post to users wall with js
我們有一個留言板,我們希望允許我們的用戶將自己的帖子交叉發布到他們的Facebook牆上。 我們已經將他們的用戶帳戶連接到他們的Facebook帳戶,以便獲得他們的Facebook個人資料圖片,並且效果很好。
我嘗試按照此處的指南(https://developers.facebook.com/docs/reference/dialogs/feed/)進行操作,第一個示例運行良好,但我們真的不希望出現對話框,因此我嘗試了“等效於Graph API”,但始終收到oauth異常#200(“此API調用需要有效的app_id。”)。
我檢查了FB.getLoginStatus並已連接,執行FB.getAccessToken()給我一個訪問令牌。
我沒有得到什么?
編輯
是的,代碼...現在我有這個:
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID',
status : true,
cookie : true,
xfbml : true
});
FB.UIServer.setLoadedNode = function(a,b){FB.UIServer._loadedNodes[a.id]=b;};
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
我可以獲取訪問令牌,並驗證登錄的Facebook用戶(我)已與匹配app_id的應用程序連接。
我也可以使用FB.ui和stream.publish方法來調用消息對話框。
我不知道的是如何在不彈出消息對話框的情況下將本地評論透明地發布到我的Facebook頁面。
有指針嗎?
預先感謝您:-)馬丁
馬丁
function shareWithFacebook() {
var photoName;
var photoUrl;
photoName = document.getElementById("ImageName").value;
photoUrl = document.getElementById("ImageUrl").value;
debugger;
var ui;
var publish;
FB.getLoginStatus(function (response) {
FB.api('/me/feed', 'post', {
message: 'I just added an image of ' + photoName + ' on http://www.yoursite.com/',
name: photoName,
link: 'http://www.yoursite.com/',
picture: photoUrl,
actions: [{ name: 'Photo', link: 'http://www.yoursite.com/'}]
}, function (response) {
if (!response || response.error) {
alert('Couldn\'t post to Facebook!');
}
else {
alert('الحمد لله');
}
}
);
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.