storage.setUserStorage “errcode":87009 "errmsg":"invalid signature
try{
$method = 'hmac_sha256';
$access_token = $this->getAccessToken();
$item = [];
$item['value'] = $level;
$item['key'] = self::USER_LEVEL_KEY;
$body = [];
$body['kv_list'][] = $item;
$signature = hash_hmac('sha256', json_encode($body), $session_key);
$url = "https://api.weixin.qq.com/wxa/set_user_storage?access_token={$access_token}&signature={$signature}&openid={$open_id}&sig_method={$method}";
$result = $this->curl_post_request($url, $body);
if(empty($result['errcode'])){
return TRUE;
}else{
throw new PadException(RespCode::BAN_SIGNUP, json_encode($result));
}
}catch (Exception $e){
MWlog::debug('Upload Fail :' . $open_id);
}
注意: 只有 kv_list
参与签名, 签名的key值是微信登录jscode2session接口的返回值 session_key。
学习记录,方便复习