Is there a way to programmatically check if a user shared a link on Facebook?

后端 未结 5 742
面向向阳花
面向向阳花 2021-01-30 11:39

I\'m currently using jQuery to record each click on a Facebook share link on my site, but I\'m looking for a more accurate solution. Instead of recording the clicks, I\'d like t

5条回答
  •  一生所求
    2021-01-30 12:34

    Here's what I do....Create the share using normal anchor that calls this javascript function (spacing or brackets or something might be off):

    FB.ui(
            {
    
                display:'iframe',
                method: 'stream.publish',
                caption: 'Put something here',
                description: 'put something here',
                name: 'foo',
                link: 'http://www.foo.com',
                picture: 'http://fo.com/img.gif'
    
            },
            function (response) {
                if (response && response.post_id) {
                //this means the post was completed....response.post_id is the FB post ID
    
                $.ajax({
                    var URL = '/pages/ajax_InsertUserFacebookPost.aspx?';
                    URL += 'facebookpostid=' + response.post_id;
                        type: "GET",
                        url: URL,
                        data: "{}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        async: true
                    });
    
    
                } else {
                    //alert('Post was not published.');
                }
            }
            );
    

提交回复
热议问题