2010-06-21 98 views
2

早上好失敗後,傳遞字符串到Twitter符號

我試圖傳遞一個字符串到Twitter,使用下面的代碼

// The message you want to send 
$message = "http://www.smartphonesoft.com/index.php?option=com_mtree&task=viewlink&link_id=" .$link_id . " " ."Android Software" . " " .$link_name . " " . $metadesc; 

// The twitter API address 
$url = 'http://twitter.com/statuses/update.xml'; 
// Alternative JSON version 
// $url = 'http://twitter.com/statuses/update.json'; 
// Set up and execute the curl process 
$curl_handle = curl_init(); 
curl_setopt($curl_handle, CURLOPT_URL, "$url"); 
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); 
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($curl_handle, CURLOPT_POST, 1); 
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message"); 
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password"); 
$buffer = curl_exec($curl_handle); 
curl_close($curl_handle); 

然而,關於Twitter的出現都是以

鏈接

http://www.smartphonesoft.com/index.php?option=com_mtree

因爲在這裏可以看到http://twitter.com/smartphonesft

如何在「&」之後通過所有內容?

回答

0

還要注意的是,如果你使用JavaScript,你需要調用encodeURIComponent()而不是encodeURI()

encodeURIComponent方法()需要以下特殊字符:

,/? : @ & = + $ #