本帖最后由 1280405008 于 2019-5-7 23:31 编辑
请帮忙根据官方文档测试一下怎么添加商品或者读取商品信息
新开了个店铺,才发现有官方接口,但是不知道怎么调用,请大佬帮帮忙
这是放心购商城平台对接文档:http://openapidoc.jinritemai.com/documents/standard.html
下面是我的店铺临时接口,做调试用
- Appkey:3343857642052433771
- Appsercet:1bec0232f2146cef5faa45107e68da17
复制代码
我用萌新助手测试总是出现 {"err_no":11,"message":"认证失败, sign校验失败"} 信息。可能是api签名问题还是其他啥的,如下图
对接文档中有php请求demo,但我看不太懂,就是下面这个
- <pre style='padding: 16px; border-radius: 3px; color: rgba(3, 17, 31, 0.87); text-transform: none; line-height: 1.45; text-indent: 0px; letter-spacing: normal; overflow: auto; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; font-style: normal; font-weight: 400; margin-top: 0px; margin-right: 0px; margin-bottom: 0px !important; margin-left: 0px; word-spacing: 0px; box-sizing: border-box; orphans: 2; widows: 2; background-color: rgb(246, 248, 250); overflow-wrap: normal; -webkit-tap-highlight-color: transparent; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;'><code style='background: none; margin: 0px; padding: 0px; border-radius: 3px; border: 0px currentColor; line-height: inherit; overflow: visible; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; display: inline; white-space: pre; word-break: normal; box-sizing: border-box; overflow-wrap: normal; -webkit-tap-highlight-color: transparent;'>header("Content-Type: text/html;charset=utf-8");
- date_default_timezone_set('PRC');
-
- $APP_KEY = 'xxx';
- $APP_SECRET = 'xxx';
-
-
- // url中base参数
- $end_time = $timestamp = date('Y-m-d H:i:s', time());
- $start_time = date('Y-m-d H:i:s', time() - 36000);
- $host = "https://openapi.jinritemai.com";
- $v = "1";
- $c = "order";
- $a = "list";
- $method = $c . "." . $a;
-
-
- // 参数按key值排序
- $param_arr = array(
- "start_time" => $start_time,
- "end_time" => $end_time,
- "order_by" => "create_time",
- "size" => "100"
- );
- ksort($param_arr);
- $param_json = json_encode($param_arr);
-
-
- // 计算签名
- $str = "app_key" . $APP_KEY . "method" . $method . "param_json" . $param_json . "timestamp" . $timestamp . "v" . $v;
- $md5_str = $APP_SECRET . $str . $APP_SECRET;
- $sign = md5($md5_str);
-
- // 构造请求url
- $base_url = $host . '/' . $c . '/' . $a . '?';
- $base_url = $host . '/' . $c . '/' . $a;
- // 生成请求url
- $url = $base_url . $query_url;
- $request_data = [
- 'app_key' => $APP_KEY,
- 'method' => $method,
- 'param_json' => $param_json,
- 'timestamp' => $timestamp,
- 'v' => $v,
- 'sign' => $sign,
- ];
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $base_url);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($request_data));
- $res = curl_exec($curl);
- curl_close($curl);
- </code></pre>
- <div> </div>
复制代码
这是官方获取商品列表的调用示例
https://openapi.jinritemai.com/product/list?app_key=your_app_key_here&method=product.list¶m_json={"page":"0","size":"20"}×tamp=2018-06-19 16:06:59&v=1&sign=your_sign_here
谁能通过我上面给出的Appkey和Appsercet 测试一下,能够返回数据就好,再教我怎么弄
日期要改到今年4月份,刚开的店铺
我QQ1280405008,能解决也可以留下qq
|