Bagaimana cara kerja nya ?
Sebenarnya hanya menggunakan script PHP biasa untuk ambil data (dengan CURL), dan di tambah dengan API facebook untuk kirim komentnya. Jadi aplikasi ini kalau di aktifkan , pada saat komentar anda di facebook di like teman / orang lain , maka otomatis akan membalas dengan kata2 "terimakasih ya , walaupun cuman robot tapi komentarku udah kamu like , hihi". kayaknya seru nih ? :D xixix .. lanjut
Awalnya saya terinspirasi dari temen di grup fb (#balikita) , dia nge share auto comment & auto respond. berhubung saya belum paham penulisan program dengan OOP , jadi saya buat sendiri dengan bahasa saya, wkwkw
tengok aja deh scriptnya di bawah..
$pesan = 'makasih ya , walaupun cuman robot tapi komentarku udah kamu like :) hihi';
$n = 50;
function bacaHTML($url){
$data = curl_init();
curl_setopt($data, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($data, CURLOPT_URL, $url);
$hasil = curl_exec($data);
curl_close($data);
return $hasil;
}
$astok = ''; //akses token yang tidak expired
$fql = 'SELECT notification_id, sender_id, title_text, object_id, body_html,object_type , href FROM notification WHERE recipient_id=me() AND is_unread = 0 AND is_hidden = 0';
$fql2 = str_replace(" ","+",$fql);
$url ='https://graph.facebook.com/fql?q='.$fql2.'&access_token='.$astok; // graph untuk tampilkan notifikasi
$kodeHTML = bacaHTML($url); // menjalankan fungsi curl diatas
$beranda = (array)json_decode($kodeHTML); // mendapatkan bentuk array dari format json
for($i=0; $i
{
$notif['object_id'][$i] = $beranda['data'][$i]->object_id;
$notif['sender_id'][$i] = $beranda['data'][$i]->sender_id;
$notif['title_text'][$i] = $beranda['data'][$i]->title_text;
}
for($i=0; $i
{
$str = $notif['title_text'][$i];
$cari = 'likes your comment';
if(strpos($str, $cari) === false){
// gak sah ngoment
}else{
$url = 'https://graph.facebook.com/'.$notif['sender_id'][$i];
$coba = bacaHTML($url);
$data = (array)json_decode($coba);
$nama = $data['name'];
$comment = str_replace("",$nama,$pesan);
echo $comments = str_replace(" ","+",$comment);
$url_comment = 'https://api.facebook.com/method/stream.addComment?post_id='.$notif['object_id'][$i].'&comment='.$comments.'&access_token='.$astok;
$ch = curl_init($url_comment);
$content = curl_exec($ch);
curl_close($ch);
}
}
?>
kalo gak tau penggunaanya comment aja ,:Dlagian masih suka dobel koment nya.. ^_^
maap ya , ini masih error :D suka dobel komennya..