Senin, 14 Februari 2011

Mengirim Pesan Yahoo Messenger (YM) Dengan Menggunakan PHP Curl

Mari kita lihat sintaxnya:
<?php
// get home page of yahoo mobile
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, “http://us.m1.yahoo.com/p/login”);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_ENCODING, “”);
curl_setopt($curl, CURLOPT_COOKIEJAR, getcwd() . ‘/cookies_yahoo_messenger.cookie’);
$curl_data = curl_exec($curl);
curl_close($curl);
// do login to yahoo messenger (mobile version)
$yahoo_id = “ID YM PENGIRIM”; // your yahoo id
$yahoo_id_password = “PSS YM PENGIRIM”; // your yahoo id password
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, “http://us.m1.yahoo.com/p/login/auth?ignore=signin”);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, “_done=&_pc=&_src=&_ts=&_sig=&_css=&_intl=&_second_user=no&username=” . $yahoo_id . “&password=” . $yahoo_id_password . “&action=Sign+in”);
curl_setopt($curl, CURLOPT_ENCODING, “”);
curl_setopt($curl, CURLOPT_COOKIEFILE, getcwd() . ‘/cookies_yahoo_messenger.cookie’);
curl_setopt($curl, CURLOPT_COOKIEJAR, getcwd() . ‘/cookies_yahoo_messenger.cookie’);
$curl_data = curl_exec($curl);
curl_close($curl);
// get home page of mobile messenger
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, “http://us.m1.yahoo.com/p/messenger”);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_ENCODING, “”);
curl_setopt($curl, CURLOPT_COOKIEFILE, getcwd() . ‘/cookies_yahoo_messenger.cookie’);
curl_setopt($curl, CURLOPT_COOKIEJAR, getcwd() . ‘/cookies_yahoo_messenger.cookie’);
$curl_data = curl_exec($curl);
curl_close($curl);
// get home page url of mobile messenger with contact lists
$url_get = $curl_data;
$url_get = substr($url_get, strpos($url_get, “/p/messenger”));
$url_get = substr($url_get, 0, strpos($url_get, “\”"));
$url_get = “http://us.m1.yahoo.com” . urldecode($url_get);
// get home page of mobile messenger with contact lists
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url_get);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_ENCODING, “”);
curl_setopt($curl, CURLOPT_COOKIEFILE, getcwd() . ‘/cookies_yahoo_messenger.cookie’);
curl_setopt($curl, CURLOPT_COOKIEJAR, getcwd() . ‘/cookies_yahoo_messenger.cookie’);
$curl_data = curl_exec($curl);
curl_close($curl);
// persiapan untuk mendapatkan variable untuk send message yahoo messenger
$url_get = $curl_data;
$url_get = substr($url_get, strpos($url_get, “/p/messenger/chat?”));
$url_get = substr($url_get, 0, strpos($url_get, “\”"));
$url_get = “http://us.m1.yahoo.com” . urldecode($url_get);
// akses ke form send message yahoo messenger
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url_get);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_ENCODING, “”);
curl_setopt($curl, CURLOPT_COOKIEFILE, getcwd() . ‘/cookies_yahoo_messenger.cookie’);
curl_setopt($curl, CURLOPT_COOKIEJAR, getcwd() . ‘/cookies_yahoo_messenger.cookie’);
$curl_data = curl_exec($curl);
curl_close($curl);
// preparation for get post url for send message
$post_url = $curl_data;
$post_url = substr($post_url, strpos($post_url, “action=”) + 8);
$post_url = substr($post_url, 0, strpos($post_url, “\”"));
$post_url = “http://us.m1.yahoo.com” . urldecode($post_url);
// target yahoo id and message
$yahoo_username = “YM PENERIMA”;
$yahoo_message = “PESAN”;
// do send message to target yahoo id
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $post_url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, “user=” . $yahoo_username . “&message=” . $yahoo_message . “&wmlfix=Send”);
curl_setopt($curl, CURLOPT_ENCODING, “”);
curl_setopt($curl, CURLOPT_COOKIEFILE, getcwd() . ‘/cookies_yahoo_messenger.cookie’);
curl_setopt($curl, CURLOPT_COOKIEJAR, getcwd() . ‘/cookies_yahoo_messenger.cookie’);
$curl_data = curl_exec($curl);
curl_close($curl);
echo “pesan Anda sudah terkirim ke Yahoo! ID: ” . $yahoo_username;
?>
Sintax diatas, itu kita melakukan login melalui yahoo mobile.
Lalu apa yang harus saya edit?
$yahoo_id = “ID YM PENGIRIM”; // your yahoo id
$yahoo_id_password = “PSS YM PENGIRIM”; // your yahoo id password
ID YM PENGIRIM = Ganti dengan id yahoo messenger anda
PSS YM PENGIRIM = Ganti dengan password id yahoo messenger anda digunakan untuk login
$yahoo_username = “YM PENERIMA”;
$yahoo_message = “PESAN”;
YM PENERIMA = Diganti dengan id YM orang yang ingin kita kirim pesan
PESAN = Diganti dengan pesan yang akan anda kirim

2 komentar:

  1. Serba Gratis...
    Gratis... Dapatkan Kalender Dinding Abadi, satu Kalender untuk semua tahun...
    Gratis... Dengan 1 akun 10 Iklan Anda akan tersebar ke berbagai Blog/Web member lain...
    Gratis... bisa menjadikan Blog/Web Anda sebagai penghasil Uang...
    Gratis... tanpa punya Blog/Web dengan fasilitas di web ini Anda bisa menghasilkan Uang...
    Gratis... Fasilitas di Web ini, pasang iklan gratis, memperpendek alamat website anda yang panjang, simpan catatan ngenet anda, buka web faforit Anda sekali klik.
    http://www.xnge.net?id=daku

    BalasHapus