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
前面的;去掉