Update Satus Facebook Menggunakan Jquery Ajax


Contoh kode kirim status ke facebook menggunakan Jquery Ajax :

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>ready demo</title>
  <style>
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>

<script>
var pesan = 'Tes pesan ....!';
</script>

<p><input type="button" value="submit" onclick="sendfb(pesan);"/></p>
<p><div id="result"/></p>

<script type='text/javascript'>
//<![CDATA[
function sendfb(message){
var token = "YourFbAppAksesToken"
var fburl = "https://graph.facebook.com/me/feed?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+'</b>');
               //});
        },
        error: function() {
        allert('error');
        }
    });
}

//]]>
</script>

</body>
</html>

Smoga bisa dikembangkan lagi....!
Previous
Next Post »