提问三步曲: 提问先看教程/FAQ索引(wdcp,wdcp_v3,一键包)及搜索,会让你更快解决问题
1 提供详细,如系统版本,wdcp版本,软件版本等及错误的详细信息,贴上论坛或截图发论坛
2 做过哪些操作或改动设置等
温馨提示:信息不详,很可能会没人理你!论坛有教程说明的,也可能没人理!因为,你懂的
[求助] 一个php异步,在服务器上,得不到支持,发出来看一下!
- function request_by_fsockopen($url,$post_data=array()){
- global $config;
- if(!strstr($url, 'http://'))
- {
- $url="http://" . $_SERVER['SERVER_NAME'] .$url;
- }
- $url_array = parse_url($url);
- $hostname = $url_array['host'];
- $port = isset($url_array['port'])? $url_array['port'] : 80;
- $requestPath = $url_array['path'] ."?". $url_array['query'];
- $fp = fsockopen($hostname, $port, $errno, $errstr, 30);
- if (!$fp) {
- echo "$errstr ($errno)";
- return false;
- }
- $method = "GET";
- if(!empty($post_data)){
- $method = "POST";
- }
-
- $header = "$method $requestPath HTTP/1.1\r\n";
- $header.="Host: ". $_SERVER['SERVER_NAME']."\r\n";
- if(!empty($post_data)){
- $_post = strval(NULL);
- foreach($post_data as $k => $v){
- $_post[]= $k."=".urlencode($v); //必须做url转码以防模拟post提交的数据中有&符而导致post参数键值对紊乱
- }
- $_post = implode('&', $_post);
- $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; //POST数据
- $header .= "Content-Length: ". strlen($_post) ."\r\n"; //POST数据的长度
- $header .= "Referer: http://".$_SERVER['SERVER_NAME']."/function.php\r\n"; //构造参数,防止外步提交!
- $header .= "AppKey: ". $config['appkey'] ."\r\n";
-
- $header.="Connection: Close\r\n\r\n";//长连接关闭
- $header .= $_post; //传递POST数据
- }else{
- $header.="Connection: Close\r\n\r\n";//长连接关闭
- }
- fwrite($fp, $header);
-
- //-----------------调试代码区间-----------------
- /*$html = '';
- while (!feof($fp)) {
- $html.=fgets($fp);
- }
- echo $html;*/
- //-----------------调试代码区间-----------------
- fclose($fp);
- }
复制代码 |