我怎样才能发布到使用Facebook的JavaScript SDK的朋友墙?发布到朋友墙使用Facebook的JavaScript的SDK
12
A
回答
4
您需要使用FB.api
方法是这样的:在FB.init
var body = 'Reading Connect JS documentation';
FB.api('/FRIEND_ID/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
10
除了@ ifaour对FB.api
答案...
- 集的OAuth和状态参数扩展许可,publish_stream,通过
FB.login
其他资源:
完整的例子...
<script>
window.fbAsyncInit = function()
{
FB.init({
appId : 'APP_ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true , // parse XFBML
oauth : true // Enable oauth authentication
});
FB.login(function(response)
{
if (response.authResponse)
{
alert('Logged in!');
// Post message to friend's wall
var opts = {
message : 'Post message',
name : '',
link : 'http://www....',
description : 'Description here',
picture : 'http://domain.com/pic.jpg'
};
FB.api('/FRIEND_ID/feed', 'post', opts, function(response)
{
if (!response || response.error)
{
alert('Posting error occured');
}
else
{
alert('Success - Post ID: ' + response.id);
}
});
}
else
{
alert('Not logged in');
}
}, { scope : 'publish_stream' });
};
</script>
<!-- FACEBOOK -->
<div id="fb-root"></div>
<script>
(function() {
var e = document.createElement('script');
// replacing with an older version until FB fixes the cancel-login bug
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
//e.src = 'scripts/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<!-- END-OF-FACEBOOK -->
-1
<script type="text/javascript">
var friendIds=new Array();;
window.fbAsyncInit = function()
{
FB.init
(
{
appId : 'appid',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true , // parse XFBML
oauth : true // Enable oauth authentication
}
);
FB.login(function(response)
{
if (response.authResponse)
{
console.log('Welcome! Fetching your information.... ');
FB.api('/me/friends/', function(response)
{
for(i=0;i<20;i++)
{
console.log('Good to see you, ' + response.data[i].name + '.');
console.log(response.data[i].id);
friendIds[i]=response.data[i].id;
}
});
}
else
{
console.log('User cancelled login or did not fully authorize.');
}
});
};
$(document).ready(function()
{
$('#shareonfacebook').click(function(e)
{
e.preventDefault();
var publish =
{
method: 'stream.publish',
name: 'DvimayPostPhoto',
link: 'http://localhost/FaceBook/index.html',
picture: 'http://www.fbrell.com/public/f8.jpg',
caption: 'hey how is my Application ? tell me dude',
description: 'hey how is my Application ?',
from: 'myid',
message: ''
};
for(i=0;i<20;i++)
{
publish.target_id = friendIds[i];
FB.ui(publish);
}
//publish.target_id = 'rupali.7';
//FB.ui(publish);
});
});
</script>
相关问题
- 1. 发布到朋友墙使用Facebook C#Sdk
- 2. 发布在使用Facebook SDK 3.0的朋友墙上的iOS
- 3. 使用iOS SDK发布评论在朋友的Facebook墙上
- 4. 如何使用C#Facebook SDK发布给朋友的墙?
- 5. Facebook Graph API发布到朋友墙
- 6. 如何发布到Facebook iOS SDK 3.1中的朋友墙?
- 7. 使用标准对话框将Facebook Facebook SDK发布到朋友的墙壁
- 8. 如何使用facebook SDK c发布在朋友墙上#
- 9. 使用Facebook IOS SDK发布给朋友墙
- 10. 如何使用Facebook PHP SDK自动发布给朋友墙
- 11. 发布在facebook上的朋友墙
- 12. iPhone - Facebook发布给朋友的墙
- 13. Facebook的 - 发布多个朋友墙壁
- 14. 发布到朋友墙
- 15. 发布在朋友的墙上使用PHP的Facebook的Facebook
- 16. 贴到朋友墙Facebook iOS SDK 3.1
- 17. 如何使用Facebook SDK将文章发布到特定朋友的墙? [android]
- 18. Facebook API发布给朋友墙
- 19. Facebook API:发布在朋友墙上
- 20. 发布使用Facebook的API(Python)的朋友的墙上
- 21. Facebook的Javascript fb.ui活动发布在朋友墙上的照片?
- 22. 使用Facebook应用发布到“您的Facebook墙和您的朋友的主页”?
- 23. 如何使用Facebook Graph API for iPhone发布到朋友墙
- 24. 使用Facebook API发布到朋友墙。 C#
- 25. 如何使用IOS中的最新Facebook sdk发布朋友墙上的文本
- 26. 通过Facebook发布在朋友墙上Actionscript 3 SDK
- 27. 如何使用php sdk发布在朋友的墙上?
- 28. 使用iPhone应用程序发布在朋友的Facebook墙上
- 29. Android如何将图片发布到朋友的墙上用facebook android sdk
- 30. iPhone App发送Facebook消息或发布到朋友的墙壁
嘿,我尝试这样做,我得到了一个HTTP POST:// myipaddress /发现/ FacebookItemRecommend 404(Not Found),为什么是这样 – aherlambang 2011-05-01 14:48:29
@aherlambang:好的,没有看到你的代码,我将无法回答你。如何在你的代码中提出一个新问题,以及你得到的错误 – ifaour 2011-05-01 14:55:45
@ifaour谢谢。它为我 – 2011-08-04 09:17:42