根据文档已经新增了临时素材获取到了icon_media_id,
但是在创建子商户时候提示调用https://api.weixin.qq.com/cgi‐bin/business/register?access_token=接口
返回了HTTP/1.1 100 Continue HTTP/1.1 404 Not Found Connection: keep-alive Date: Tue, 03-Sep-2019 01:17:44 GMT Content-Length: 0
以下是php后端代码
public function add_mcustomer(){
$data['icon_media_id']='-Z3OVGVRiIUpV2WfUkfLSSQKpEIUVxJfUtlXTxdY2as5gfGyeUgrJuwQ8YGOmXgQ';
$data['nickname']='小李飞刀';
$data['account_name']='测试';
$TOKEN=$this->getAccessToken();
$URL='https://api.weixin.qq.com/cgi‐bin/business/register?access_token='.$TOKEN;
$res =$this->http_request($URL,$data);
var_dump($res);exit;
}
public function http_request($url,$post_data = null) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
$data = curl_exec($curl);
if($data === false)
{
echo 'Curl error: ' . curl_error($curl);
}
//关闭URL请求
curl_close($curl);
return $data;
}
public function getAccessToken(){
$APPID="xxxxxx";
$APPSECRET="xxxxxxxxxxxx";
$info=json_decode(file_get_contents("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$APPID&secret=$APPSECRET"));
//获取token
$access_token=$info->access_token;
return $access_token;
}
你好!接口地址写错了,应该是重文档复制下来的。cgi-bin 里面含有特殊字符。
https://api.weixin.qq.com/cgi-bin/business/register
你好! 请问一下icon_media_id 是要从与小程序关联的任何一个公众号获取就可以吗