Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X

Posts tagged ‘curl’

Kenar

PHP ile WordPress Bloga Yazı Eklemek (XMLRPC)

Çoğu zaman yazıyı elle eklemek zor oluyor heleki PHP ile sitelerinde hazır bot kullanan arkadaşlar için :)

İlk öncelikle yönetim panelinden Settings kısmından Writing e tıklayarak sayfanın altında XML-RPC'yi etkin etmemiz gerekiyor harici bir dosyadan veri ekleyebilmemiz için.

PHP:
  1. function wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$category,$keywords='') {
  2.    
  3.     $content = array(
  4.         'title'=>$title,
  5.         'description'=>$body,
  6.         'mt_allow_comments'=>1// Yoruma izin vermek için 1 yapın
  7.         'mt_allow_pings'=>1// Trackbacks için 1 yapın
  8.         'post_type'=>'post',
  9.         'mt_keywords'=>$keywords,
  10.         'categories'=>array($category)
  11.     );
  12.     $params = array(0,$username,$password,$content,true);
  13.     $request = xmlrpc_encode_request('metaWeblog.newPost',$params);
  14.     $ch = curl_init();
  15.     curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
  16.     curl_setopt($ch, CURLOPT_URL, $rpcurl);
  17.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  18.     curl_setopt($ch, CURLOPT_TIMEOUT, 1);
  19.     $results = curl_exec($ch);
  20.     curl_close($ch);
  21.     return $results;
  22. }

Bu fonksiyon daha hızlı kullanmanız için :)

PHP:
  1. $Baslik = 'BAŞLIK';
  2. $Icerik = 'YAZI İÇİ';
  3. $XMLPCDosyasi = 'http://www.wpsiteminadresi.com/xmlrpc.php';
  4. $KullaniciAdi = 'admin';
  5. $Sifre = 'kullanicisifrem';
  6. $Kategoriler = 'Haber,Oyun,Spor'; // Virgüllerle ayırarak kategori isimlerini yazmanız gerekmektedir.
  7. $Etiketler = 'xxx,yyy,zzz,aaa,eee,ppp,sss'; // Virgüllerle ayırarak istediğiniz kadar yazabilirsiniz.
  8.  
  9. echo wpPostXMLRPC($Baslik,$Icerik,$XMLPCDosyasi,$KullaniciAdi,$Sifre,$Kategoriler,$Etiketler);

Hayırlı uğurlu olsun :)

Unutmadan cURL sunucuda aktif olması gerekmektedir.

Sizin için hazırlamış olduğum dosyayı indirerek direkt olarak deneyebilirsiniz.

Kenar

cURL & php ile FriendFeed’e kayıt girişi yapmak

fflogo friendfeed.com u bilmeyenimiz kalmadı sanırım tekrar açıklamaya gerek yoktur.

Daha önceden delicious ve twitter a curl ile yazı gönderimini işlemiştik.

Şimdide sıra friendfeed'e geldi.

İnternette aradım pek bişi bulamadım deneyerek ortaya çıktı kodlar :)

Friendfeed de daha öncekilerde olduğu gibi direk şifreniz ile işlem yapamıyorsunuz.

https://friendfeed.com/account/api adresinden Remote Key almanız gerekmektedir.

Ve işte kodlar;

PHP:
  1. $ff_api_url = "http://friendfeed-api.com/v2/entry";
  2. $ff_data = "body=".$Baslik."&link=".$Linkiniz."&comment=".$Yorumu_Aciklama."&image_url=".$ResimVarsaAdresi;
  3. $ff_user = "KullaniciAdiniz";
  4. $ff_password = "AlmisOldugunuzRemoteKey";
  5. $ch = curl_init($ff_api_url);
  6. curl_setopt($ch, CURLOPT_POST, 1);
  7. curl_setopt($ch, CURLOPT_POSTFIELDS, $ff_data);
  8. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  9. curl_setopt($ch, CURLOPT_HEADER, 0);
  10. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  11. curl_setopt($ch, CURLOPT_USERPWD, "{$ff_user}:{$ff_password}");
  12. $twitter_data = curl_exec($ch);
  13. $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  14. curl_close($ch);
  15. if ($httpcode != 200) {
  16.     echo "<strong>Friendfeed</strong> HATA<br />";
  17.     } else {
  18.     echo "<strong>Friendfeed</strong> OK<br />";
  19.     }

güle güle kullanımlar ;)

Kenar

cURL & php ile delicious’a otomatik yazı gönderme

delicious_logo

Daha önce curl ile twitter'a post atma işlemini incelemiştik şimdide sıra geldi delicious'a :)

PHP:
  1. $dusername = 'KullaniciAdi';
  2. $dpassword = 'Sifre';
  3. $link = urlencode('$yaziLinki');
  4. $desc = urlencode($yazi_baslik);
  5. $ext = urlencode($yazi_aciklama);
  6. $deltags = urlencode($yazi_etiket);
  7.  
  8. $api = "api.del.icio.us/v1";
  9.  
  10. $apicall = "https://$dusername:$dpassword@$api/posts/add?&amp;url=$link&amp;description=$desc&amp;extended=$ext&amp;tags=$deltags";
  11. $ch = curl_init();
  12. curl_setopt($ch, CURLOPT_URL,$apicall);
  13. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  14. curl_setopt($ch, CURLOPT_USERAGENT, 'php-curl');
  15. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  16. $xml = curl_exec ($ch);
  17. $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  18. curl_close($ch);
  19. if ($httpcode != 200) {
  20. echo "<strong>Delicious</strong> HATA";
  21. } else {
  22. echo "<strong>Delicious</strong> OK";
  23. }