2010-06-21 100 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方法()需要以下特殊字符:

,/? : @ & = + $ #