Curl ile Twitpic sitesine resim upload etmek

[XFB] Konu Bilgileri

Konu Hakkında Merhaba, tarihinde Hazır Kod Bankası kategorisinde Systemweb tarafından oluşturulan Curl ile Twitpic sitesine resim upload etmek başlıklı konuyu okuyorsunuz. Bu konu şimdiye dek 120 kez görüntülenmiş, 2 yorum ve 2 tepki puanı almıştır...
Kategori Adı Hazır Kod Bankası
Konu Başlığı Curl ile Twitpic sitesine resim upload etmek
Konuyu başlatan Systemweb
Başlangıç tarihi
Cevaplar
Görüntüleme
İlk mesaj tepki puanı
Son Mesaj Yazan WebAjans

Systemweb

katmod
Curl ile Twitpic sitesine resim upload etmek

Kod:
$file = $_FILES['media']; 

if (!in_array($file['type'], array('image/png','image/jpeg','image/gif'))) { [/B] [B]
echo '<span style="color:#CC0000;">Not a valid file type, please upload PNG, JPEG or GIF images only.</span>'; 
exit; 
} 

$postfields = array(); [/B] [B]
$postfields['username'] = $username; 
$postfields['password'] = $password; 
$postfields['media'] = "@$file['tmp_name']";

$twitter_url = 'http://twitpic.com/api/upload'; [/B] [B]
$curl = curl_init(); 
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2); 
curl_setopt($curl, CURLOPT_HEADER, false); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); 
curl_setopt($curl, CURLOPT_URL, $twitter_url); 
curl_setopt($curl, CURLOPT_POST, 3); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields); 
$result = curl_exec($curl); 
curl_close($curl); 
$login_xml = new SimpleXMLElement($result); 
if (isset($login_xml->error)) { 
print_r($login_xml); 
} else { 
print_r($login_xml); 
}
 
Üst