20,360
社区成员
发帖
与我相关
我的任务
分享
public function post_api(){
//测试商户号 013113052300
//测试密钥 j0x9skv6oujnrodqadpgdgtqdzbtg8ji
$url = "http://123.207.31.97:1083/pospay/gatewayPay";
$sing = 'api_type=GATEWAY&char_type=UTF-8&data=';
$sing.= '<xml>';
$sing.= '<mch__create__ip>139.199.172.76</mch__create__ip>';
$sing.= '<mch__trade__no>No20170710160025</mch__trade__no>';
$sing.= '<total__fee>1</total__fee>';
$sing.= '<product__name>xxx</product__name>';
$sing.= '<time__start>20170710160025</time__start>';
$sing.= '<return__url>http://139.199.172.76/Admin/Crj/recharge.html</return__url>';
$sing.= '<notify__url>http://139.199.172.76/Admin/Crj/recharge.html</notify__url>';
$sing.= '</xml>';
$sing.= '&data_type=xml&mch_id=013113052300&nonce_str=20170710160025&sign_type=MD5&ver_no=1.08n649qgjphde1l2qf83ri9094tddciky';
$sing_data = md5($sing);
$res = $this->request_post($url,$sing_data);
// $res = $this->CurlFile($url,$sing_data);
print_r($res);
}
public function request_post($url = '', $param = '') {
if (empty($url) || empty($param)) {
return false;
}
$postUrl = $url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页
curl_setopt($ch, CURLOPT_HEADER,false);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
$data = curl_exec($ch);//运行curl
curl_close($ch);
return $data;
}
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
会不会是header错误呢
这段java代码转为php代码 该怎么写。。