[英]Problems with FB.api
我编写了以下代码,但是由于某些原因, FB.api无法正常工作。 我可以这么说是因为javascript控制台中没有日志消息。 我已经对用户进行了身份验证并获得了publish_stream权限。以下代码位于FB.login块内部(希望这不是问题)。我已经使用jQuery,因为我已经知道如何使用它来进行get请求。
jQuery.ajax( {
url: access,
dataType: 'json',
success: function (resp) {
var data_item='This is a successful post plz do not comment this is a test';
FB.api('me/feed', 'post', {message: data_item}, function(response) {
if (!response || response.error) {
console.log('Error occured');
} else {
console.log('Post ID: ' + response.id);
}
});
有什么帮助或建议吗?
您需要指定访问令牌,我遇到了同样的问题..我只添加了访问令牌并解决了问题..
在这里看看: http : //www.friendouh.com/
jQuery.ajax( {
url: access,
dataType: 'json',
success: function (resp) {
var data_item='This is a successful post plz do not comment this is a test';
FB.api('me/feed', 'post', {message: data_item,access_token: 'your_acess_token'}, function(response) {
if (!response || response.error) {
console.log('Error occured');
} else {
console.log('Post ID: ' + response.id);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.