這裡提供一個透過TWSMS發送簡訊的小範例,利用Zend Framework所提供的Zend_Http蠻方便的~
$message = urlencode("測試中文"); $client = new Zend_Http_Client(); $client->setUri("http://api.twsms.com/send_sms.php?username=xxxx&password=xxxx&type=now&encoding=big5&mobile=09xxxxxxxx&message=$message&vldtme=3600"); $client->setConfig(array( 'maxredirects' => 0, 'timeout' => 30) ); $client->setMethod(Zend_Http_Client::GET); $response = $client->request(); if ($response->isError()) { echo "Server reply was: " . $response->getStatus() . " " . $response->getMessage() . "\n"; }else{ $body = $response->getBody(); echo $body; }