日期:2011-09-26  浏览次数:20781 次

 

1. 发送短信

调用 TextMagic API。


  1. 		// Include the TextMagic PHP lib  
  2. require('textmagic-sms-api-php/TextMagicAPI.php');  
  3.  
  4. // Set the username and password information  
  5. $username = 'myusername';  
  6. $password = 'mypassword';  
  7.  
  8. // Create a new instance of TM  
  9. $router = new TextMagicAPI(array(  
  10.     'username' => $username,  
  11.     'password' => $password 
  12. ));  
  13.  
  14. // Send a text message to '999-123-4567'  
  15. $result = $router->send('Wake up!', array(9991234567), true);  
  16.  
  17. // result:  Result is: Array ( [messages] => Array ( [19896128] => 9991234567 ) [sent_text] => Wake up! [parts_count] => 1 ) 

2. 根据IP查找地址


  1. 		function detect_city($ip) {  
  2.  
  3.         $default = 'UNKNOWN';  
  4.  
  5.         if (!is_string($ip)  strlen($ip) < 1  $ip == '127.0.0.1'  $ip == 'localhost')  
  6.             $ip = '8.8.8.8';  
  7.  
  8.         $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)';  
  9.  
  10.         $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip);  
  11.         $ch = curl_init();  
  12.  
  13.         $curl_opt = array(  
  14.             CURLOPT_FOLLOWLOCATION  => 1,  
  15.             CURLOPT_HEADER      => 0,  
  16.             CURLOPT_RETURNTRANSFER  => 1,  
  17.             CURLOPT_USERAGENT   => $curlopt_useragent,  
  18.             CURLOPT_URL       => $url,  
  19.             CURLOPT_TIMEOUT         => 1,  
  20.             CURLOPT_REFERER         => 'http://' . $_SERVER['HTTP_HOST'],  
  21.