简体   繁体   English

Titanium facebook喜欢按钮

[英]Titanium facebook like button

I try to publish like for page from my Titanium Alloy application. 我尝试从我的Titanium Alloy应用程序发布类似于页面的内容。

var fb = require('facebook');
fb.appid = "1234567890";
fb.permissions = ['public_profile', 'email', 'publish_actions'];

fb.addEventListener('login', function(e) {
    if (e.success) {
        Ti.API.info('LOGIN : Logged In');
    } else if (e.error) {
        Ti.API.info('LOGIN : ' + e.error);
    } else if (e.cancelled) {
        Ti.API.info('LOGIN : Canceled');
    }
    publishLike();
});

function publishLike() {
    var dict = {
        access_token : fb.getAccessToken()
    };
    fb.requestWithGraphPath('/' + 'somePageId' + '/likes', dict, 'POST', function(e) {
        if (e.success) {
            Ti.API.info('publishLike : Success!');
        } else {
            if (e.error) {
                Ti.API.info('publishLike : ' + e.error);
            } else {
                Ti.API.info('publishLike : Unkown result');
            }
        }
    });
}

But error appeared when app make API call: 但是当应用程序进行API调用时出现错误:

[ERROR] :  FacebookModule: (Thread-1559) [9475,21411] Request error for '/somePageId/likes' call: (#3) Application does not have the capability to make this API call.
[ERROR] :  FacebookModule: com.facebook.android.FacebookError: (#3) Application does not have the capability to make this API call.
[ERROR] :  FacebookModule:  at com.facebook.android.Util.parseJson(Util.java:303)
[ERROR] :  FacebookModule:  at facebook.TiRequestListener.onComplete(TiRequestListener.java:88)
[ERROR] :  FacebookModule:  at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:276)
[INFO] :   publishLike : (#3) Application does not have the capability to make this API call.

Do you have any ideas how to publish like? 你有什么想法如何发布?

According to this answer you cannot like pages from the Graph API. 根据这个答案,你不能喜欢Graph API中的页面。 That is because you can only like an Open Graph object with the API but pages are no Open Graph objects. 这是因为您只能使用API​​的Open Graph对象,但页面不是Open Graph对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM