Update Comment Facebook Menggunakan Jquery Ajax


Contoh kode mengirimkan komentar Facebook menggunakan Jquery Ajax :

<script>
var pesan = 'Tes pesan ....!';
var mytoken = "TokenApplicationFbAnda"
var post = '973059202765070';
</script>

<p>Send Comment : <input type="button" value="submit" onclick="sendcomment(pesan,post,mytoken);"/></p>
<p><div id="result"/></p>

<script type='text/javascript'>
//<![CDATA[

function sendcomment(message,postID,token){
var fburl = "https://graph.facebook.com/"+postID+"/comments?message="+message+"&access_token="+token;
$.ajax({
        url: fburl,
        type: "post",
        dataType: "json",
        success: function(data) { 
               //$.each(data, function(i,data){
               $('#result').append('<b>'+data.id.replace(postID+"_",'')+'</b>');
               //});
        },
        error: function() {
        allert('error');
        }
    });
}

//]]>
</script>

Smoga bermanfaat.....!
Previous
Next Post »