|
|
发表于 10-2-2010 11:29 PM
|
显示全部楼层
PHP Sample- <?php
- $ur_server_user = "admin";
- $ur_server_password = "abc123";
- $ur_server_url = "http://127.0.0.1:9501/api?";
- function httpRequest($url){
- $pattern = "/http...([0-9a-zA-Z-.]*).([0-9]*).(.*)/";
- preg_match($pattern,$url,$args);
- $in = "";
- $fp = fsockopen("$args[1]", $args[2], $errno, $errstr, 30);
- if (!$fp) {
- return("$errstr ($errno)");
- } else {
- $out = "GET /$args[3] HTTP/1.1\r\n";
- $out .= "Host: $args[1]:$args[2]\r\n";
- $out .= "User-agent: Ozeki PHP client\r\n";
- $out .= "Accept: */*\r\n";
- $out .= "Connection: Close\r\n\r\n";
- fwrite($fp, $out);
- while (!feof($fp)) {
- $in.=fgets($fp, 128);
- }
- }
- fclose($fp);
- return($in);
- }
- function urServerSend($phone, $msg, $debug=false){
- global $ur_server_user,$ur_server_password,$ur_server_url;
- $url = 'username='.$ur_server_user;
- $url.= '&password='.$ur_server_password;
- $url.= '&action=sendmessage';
- $url.= '&messagetype=SMS:TEXT';
- $url.= '&recipient='.urlencode($phone);
- $url.= '&messagedata='.urlencode($msg);
- $urltouse = $ur_server_url.$url;
- if ($debug) { echo "Request: <br>$urltouse<br><br>"; }
- //Open the URL to send the message
- $response = httpRequest($urltouse);
- if ($debug) {
- echo "Response: <br><pre>".
- str_replace(array("<",">"),array("<",">"),$response).
- "</pre><br>"; }
- return($response);
- }
- ########################################################
- # GET data from sendsms.html
- ########################################################
- $phonenum = $_POST['recipient'];
- $message = $_POST['message'];
- $debug = true;
- urServerSend($phonenum,$message,$debug);
- ?>
复制代码 注意,只是sample
要看你的server的variable来改 |
|