收藏
回答

微信小商店交易组件搜索商品为什么搜索不到?

$url = 'https://api.weixin.qq.com/product/spu/search?access_token='.$access_token;
$params = [
    'source' => 1,
    'page' => 1,
    'page_size' => 10,
    'keyword' => '方圆图',
];

appid:wx8c57701ead77cd40

文档链接:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent/API/spu/search_spu.html


回答关注问题邀请回答
收藏

2 个回答

  • ak47
    ak47
    03-04
    def call_search():
        print(f"self.access_token----{self.access_token}")
        import urllib.parse
        post_data = {
            "keyword": "乌合之众",
            'source': 1,
            'page': 1,
            'page_size': 10
        }
    
        headers = {'Content-Type': 'application/json; charset=UTF-8'}
        data = json.dumps(post_data, ensure_ascii=False)
        response_data = requests.post(f'https://api.weixin.qq.com/product/spu/search?access_token={self.access_token}', data=data.encode('utf-8'), headers=headers)
        res_data = response_data.json()
        print(f"res_data------{res_data}")
        return res_data
    

    贴一段python的代码 希望兄弟们别踩坑

    03-04
    有用
    回复
  • 请叫我星哥
    请叫我星哥
    2023-09-11

    php post 提交需要中文不转码:json_encode($data, JSON_UNESCAPED_UNICODE)

    function curl_post($url, $data) {
          $data = json_encode($data, JSON_UNESCAPED_UNICODE);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    		'Content-Type: application/json;charset=UTF-8;'
    		)
        );
        $handles = curl_exec($ch);
        curl_close($ch);
        return json_decode($handles, true);
    }
    
    2023-09-11
    有用
    回复
登录 后发表内容