微信开放平台,第三方平台代小程序实现业务,修改小程序头像的接口,根据接口要求上传
发布于 4 年前 作者 jinming 4070 次浏览 来自 问答

使用永久素材和临时素材都报错 invalid media_id hint

$postUrl = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=$token&type=$type";
$ch = curl_init();
$url = str_replace(env('CDN_URL'), public_path(), $url);
$file = new \CURLFile($url);
// \Log::info($file);
$data = array('name' => 'media', 'file' => $file);

临时素材接口返回

在微信接口调试工具验证这个mediaid是正确的

接下来提交到头像修改接口直接报错

$setNicknameUrl = 'https://api.weixin.qq.com/cgi-bin/account/modifyheadimage?access_token='.$auth_info['authorizer_access_token'];
$postData['head_img_media_id'] = $res['media_id'];
$postData['x1'] = (float)0;
$postData['y1'] = (float)0;
$postData['x2'] = (float)1;
$postData['y2'] = (float)1;
$res = $this->curl_post($setNicknameUrl, $postData, 'json');

请问这种情况是怎么回事呢

1 回复

你好,你这里使用错了接口哦

新增临时素材的接口在这:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738726

回到顶部