$url = 'https://api.weixin.qq.com/cgi-bin/component/fastregisterweapp?action=create&component_access_token='.$token;
$postData['name'] = (string)$data['companyName'];
$postData['code'] = (string)$data['companyCode'];
$postData['code_type'] = intval($data['companyCodeType']);
$postData['legal_persona_wechat'] = (string)$data['legalPersonaWechat'];
$postData['legal_persona_name'] = (string)$data['legalPersonaName'];
$postData['component_phone'] = (string)$data['componentPhone'];
$res = _postJsonRequest($url,$data);
function _postJsonRequest($url, $data)
{
$ch = curl_init();
if (!$data) {
$data = [];
}
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
$header = [];
$header[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1); // 设置请求为post类型
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // 添加post数据到请求中
$output = curl_exec($ch);//执行并获取HTML文档内容
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);//释放curl句柄
if ($http_code == 200) {
return $output;
} else {
return false;
}
}
一直提示:
一直在47001,我打印出来也是符合要求的,有点费解这个问题。
code的位数我确认无误
对不起,我是鸹貔。