Facebook like button

You must Login before you can answer or comment on any questions.

Hi.

I have tried to make a FB like button to like statuses from my page.

This is what i have and i get success message but no like is recorded on FB.

What have i missed?

var like = Ti.UI.createImageView({
 
    width   : 75,
    top     : 270,
 
    image   : 'images/check.png',
    zIndex  : 10
});
win.add(like);
 
 
like.addEventListener('click', function(e) {
Titanium.Facebook.appid = "1234567890";
Titanium.Facebook.permissions = ['publish_stream', 'read_stream', "user_checkins", "publish_checkins"];
var dict = {
        access_token : Titanium.Facebook.getAccessToken()
    }
    Titanium.Facebook.requestWithGraphPath(+win.id+'/likes', dict, 'POST', function(e) {
        if(e.success) {
            alert('Success! From FB: ');
        } else {
            if(e.error) {
                alert(e.error);
            } else {
                alert('Unkown result');
            }
        }
    });
});

— asked 12 months ago by Richard Harrysson
2 Comments
  • This looks like you are requesting the likes of the user, not setting the user's like of something...

    — commented 11 months ago by Peter Kootsookos

  • Yes i had it all wrong.

    I have to post something (Message)to the graph to make it like it. (?) I dont know why but now this works. like clockwork!

    var like = Titanium.UI.createImageView({
       image: 'images/like.png',
       bottom: 6,
       width: 48,
       height: 30,
       left: 12,  
     
     
    });
     
    win.add(like);
     
     
     
    like.addEventListener('click',function(e)
    {
     
     
        if(Ti.Facebook.loggedIn && !(Titanium.Network.networkType == Titanium.Network.NETWORK_NONE)) {
            var data = {
                link : "https://www.facebook.com/308xxxxxxxx",
                name : "Like iPhone App",
                message :  "Jag gillade precis statusuppdateringen:\n  \"" + ta1.value + "\"\n från The Likes genom min coola app. Ladda ner den du med!",
                caption : "För info om nedladdning kan du klicka på länken här ovanför.",
                picture : "http://www.likeinthenight.com/test.jpg",
                description : "Med Likes iPhone app kan du på ett smidigt sätt få alla nyheter, evenmang, senaste bilderna etc direkt i din mobil."
            };
     
            Titanium.Facebook.requestWithGraphPath('/' + win.id + '/likes', data, 'POST', function(e) {
                if(e.success) {
         var d = Titanium.UI.createAlertDialog({
       title: 'Like',
       message: 'U have liked the status',
       buttonNames: ['Ok'],
    });
    d.addEventListener('click',function(e){ 
        });
     
    d.show();
                }
                if(e.error) {
                    alert(e.error);
                }
            });
     
        }
    win.id is the id of the status i want to like. If i remove the message than it wont record any likes.

    Thanx.

    — commented 11 months ago by Richard Harrysson

Your Answer

Think you can help? Login to answer this question!