asp傳送簡訊功能怎麼改成php的,有asp例子,求教

來源:互聯網
上載者:User
If vercode > "" Thenemail = "介面簡訊的使用者帳號"SMS_PASSWORD = "介面簡訊的使用者密碼"DescURL = "http://www.xxxx.com.cn/api/send.asp"  //介面地址Set objHTTP = Server.CreateObject("MSXML2.XMLHTTP")Call objHTTP.Open("POST", DescURL, FALSE)PostData = "email="+email+"&Password="+SMS_PASSWORD+"&MsgContent="+((MsgContent))+"&mobileNumber="+ m +"&SendTime="+SendTime+"&SubNumber="+ SubNumber  //一些上邊的變數拼接,有使用者名稱,密碼,發送手機號等Response.Write postdataCall objHTTP.SetRequestHeader("Content-Type","text/html; charset=uft-8")Call objHTTP.open("GET",DescURL & "?" & PostData, false)Call objHTTP.send()end if



這是asp的寫法,有點彆扭。 要換成php怎麼寫啊?先謝謝了!


回複討論(解決方案)

用curl類似的

file_get_contents($url);

authentication = 0;       if($use == true) $this->authentication = 1;     }      public function setName($name){       $this->auth_name = $name;     }     public function setPass($pass){       $this->auth_pass = $pass;     }      public function __construct($url,$followlocation = true,$timeOut = 30,$maxRedirecs = 4,$binaryTransfer = false,$includeHeader = false,$noBody = false)     {         $this->_url = $url;         $this->_followlocation = $followlocation;         $this->_timeout = $timeOut;         $this->_maxRedirects = $maxRedirecs;         $this->_noBody = $noBody;         $this->_includeHeader = $includeHeader;         $this->_binaryTransfer = $binaryTransfer;          $this->_cookieFileLocation = dirname(__FILE__).'/cookie.txt';      }      public function setReferer($referer){       $this->_referer = $referer;     }      public function setCookiFileLocation($path)     {         $this->_cookieFileLocation = $path;     }      public function setPost ($postFields)     {        $this->_post = true;        $this->_postFields = $postFields;     }      public function setUserAgent($userAgent)     {         $this->_useragent = $userAgent;     }      public function createCurl($url = 'nul')     {        if($url != 'nul'){          $this->_url = $url;        }          $s = curl_init();          curl_setopt($s,CURLOPT_URL,$this->_url);         curl_setopt($s,CURLOPT_HTTPHEADER,array('Expect:'));         curl_setopt($s,CURLOPT_TIMEOUT,$this->_timeout);         curl_setopt($s,CURLOPT_MAXREDIRS,$this->_maxRedirects);         curl_setopt($s,CURLOPT_RETURNTRANSFER,true);         curl_setopt($s,CURLOPT_FOLLOWLOCATION,$this->_followlocation);         curl_setopt($s,CURLOPT_COOKIEJAR,$this->_cookieFileLocation);         curl_setopt($s,CURLOPT_COOKIEFILE,$this->_cookieFileLocation);          if($this->authentication == 1){           curl_setopt($s, CURLOPT_USERPWD, $this->auth_name.':'.$this->auth_pass);         }         if($this->_post)         {             curl_setopt($s,CURLOPT_POST,true);             curl_setopt($s,CURLOPT_POSTFIELDS,$this->_postFields);          }          if($this->_includeHeader)         {               curl_setopt($s,CURLOPT_HEADER,true);         }          if($this->_noBody)         {             curl_setopt($s,CURLOPT_NOBODY,true);         }         /*         if($this->_binary)         {             curl_setopt($s,CURLOPT_BINARYTRANSFER,true);         }         */         curl_setopt($s,CURLOPT_USERAGENT,$this->_useragent);         curl_setopt($s,CURLOPT_REFERER,$this->_referer);          $this->_webpage = curl_exec($s);                   $this->_status = curl_getinfo($s,CURLINFO_HTTP_CODE);         curl_close($s);      }    public function getHttpStatus()   {       return $this->_status;   }    public function __tostring(){      return $this->_webpage;   }} $m=new mycurl("http://www.xxxx.com.cn/api/send.asp"); //一些上邊的變數拼接,有使用者名稱,密碼,發送手機號$m->setPost(Array("email"=> $email, "Password"=> $SMS_PASSWORD,"MsgContent"=> $MsgContent,"mobileNumber"=> $mobileNumber,"SendTime"=> $SendTime,"SubNumber"=> $SubNumber    ));$m->createCurl();?>

你看這樣是否能用



你看這樣是否能用




怎麼調用啊? 小弟不才, 我用的CI架構,這個類,我怎麼讓他執行,謝謝!






調用send方法,在方法中包含進來你寫的檔案,把資訊都填好了。出現

Fatal error: Call to undefined function curl_init() in D:\Program\wamp\www.huarenbeiphp2.com\application\controllers\mycurl.php on line 75

http://www.cmhello.com/enable-curl-of-wamp.html

函數裡面定義類,初始化,這倒是也可以工作。

建議參考下 http://codeigniter.org.cn/user_guide/general/creating_libraries.html

Fatal error: Call to undefined function curl_init()
這個錯誤需要你把php.ini設定檔中的

;extension=php_curl.dll

前面的;去掉
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.