EBusinessID, 'RequestType' => '1001', 'RequestData' => urlencode($requestData) , 'DataType' => '2', ); $datas['DataSign'] = encrypt($requestData, AppKey); $result=sendPost(ReqURL, $datas); //根据公司业务处理返回的信息...... return $result; } /** * XML方式 在线下单 */ function orderOnlineByXml(){ $requestData= "". "". "1.5". "test_123456". "0.5". "测试在线下单接口 20150510". "1". "1". "1000". "1". "2015-05-10 19:36:50". "2015-05-11 19:36:50". "LB". "". "张三". "深圳市南山区南新路2055号". "". "13800000000". "". "广东省". "深圳市". "南山区". "快递鸟科技". "李四". "深圳市福田区华强北路211号". "". "13888888888". "". "广东省". "深圳市". "福田区". "12". "1". "". "". "惠普显示器". "ABCD_123456789". "2". "850". "". "". "神州笔记本". "QWERT_456456". "2". "4200". "". "". ""; $datas = array( 'EBusinessID' => EBusinessID, 'RequestType' => '1001', 'RequestData' => urlencode($requestData) , 'DataType' => '1', ); $datas['DataSign'] = encrypt($requestData, AppKey); $result=sendPost(ReqURL, $datas); //根据公司业务处理返回的信息...... return $result; } /** * post提交数据 * @param string $url 请求Url * @param array $datas 提交的数据 * @return url响应返回的html */ function sendPost($url, $datas) { $temps = array(); foreach ($datas as $key => $value) { $temps[] = sprintf('%s=%s', $key, $value); } $post_data = implode('&', $temps); $url_info = parse_url($url); $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n"; $httpheader.= "Host:" . $url_info['host'] . "\r\n"; $httpheader.= "Content-Type:application/x-www-form-urlencoded\r\n"; $httpheader.= "Content-Length:" . strlen($post_data) . "\r\n"; $httpheader.= "Connection:close\r\n\r\n"; $httpheader.= $post_data; $fd = fsockopen($url_info['host'], 80); fwrite($fd, $httpheader); $gets = ""; while (!feof($fd)) { $gets.= fread($fd, 128); } fclose($fd); return $gets; } /** * 电商Sign签名生成 * @param data 内容 * @param appkey Appkey * @return DataSign签名 */ function encrypt($data, $appkey) { return urlencode(base64_encode(md5($data.$appkey))); } ?>