Archive for Mayıs 26th, 2009
cURL & php ile twitter’a otomatik yazı gönderme

PHP:
-
$twitter_api_url = "http://twitter.com/statuses/update.xml";
-
$twitter_data = "status=Buraya Link ve Açıklama Yazabilirsiniz";
-
$twitter_user = "KullaniciAdi";
-
$twitter_password = "Sifre";
-
$ch = curl_init($twitter_api_url);
-
curl_setopt($ch, CURLOPT_POST, 1);
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $twitter_data);
-
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
-
curl_setopt($ch, CURLOPT_HEADER, 0);
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-
curl_setopt($ch, CURLOPT_USERPWD, "{$twitter_user}:{$twitter_password}");
-
$twitter_data = curl_exec($ch);
-
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
-
curl_close($ch);
-
if ($httpcode != 200) {
-
echo "Twitter HATA";
-
} else {
-
echo "Twitter OK&";
-
}
Yapmanız gereken cURL destekleyen bir sunucunuz var ise istediğiniz makale veya yazılarınızı otomatik olarak twitter hesabınıza post etmenize yardımcı olur.
Kolay Gelsin