client_id = $client_id; $this->client_secret = $client_secret; if ($access_token !== null) $this->access_token = $access_token; } /** * 获取授权url * * 授权说明 https://open.pinduoduo.com/application/document/browse?idStr=BD3A776A4D41D5F5 * @param unknown $redirect_uri * @param unknown $state */ public function getWebAuthUrl($redirect_uri, $state) { return "https://fuwu.pinduoduo.com/service-market/auth?response_type=code&client_id=".$this->client_id."&redirect_uri={$redirect_uri}&state={$state}"; } public function getAccessToken($code) { $params = $this->getPublicParams(); $params['type'] = 'pdd.pop.auth.token.create'; $params['code'] = $code; $params['sign'] = $this->getSignature($params); return $this->postRequest(json_encode($params)); } /** * 订单详情 * https://open.pinduoduo.com/application/document/api?id=pdd.order.information.get * * 查询单个订单详情(只能获取到成交时间三个月以内的交易信息) * {"order_info_get_response":{"request_id":"16547568855546893","order_info":{"support_nationwide_warranty":0,"country":"中国","group_status":1,"free_sf":0,"discount_amount":0.0,"platform_discount":0.0,"return_freight_payer":0,"order_status":1,"id_card_num":"","risk_control_status":0,"province":"","town_id":0,"item_list":[{"goods_name":"checkpass论文查重无限次数低价免注册查重","outer_goods_id":"","goods_price":1.0,"goods_id":329073007863,"sku_id":1115504481445,"goods_count":1,"goods_spec":"千字符","outer_id":"","goods_img":"https://img.pddpic.com/mms-material-img/2022-03-28/0c075d33-b036-46f7-a0bf-d40774f68190.png.a.jpeg"}],"pay_no":"","last_ship_time":"2022-06-11 14:37:23","delivery_one_day":0,"created_time":"2022-06-09 14:37:14","card_info_list":[],"refund_status":1,"town":"","is_stock_out":0,"receiver_address_mask":"","receive_time":"","pay_time":"2022-06-09 14:37:23","gift_list":[],"capital_free_discount":0.0,"receiver_phone_mask":"13*******67","country_id":0,"city_id":0,"invoice_status":0,"service_fee_detail":[],"city":"","order_tag_list":[{"name":"delivery_one_day","value":0},{"name":"no_trace_delivery","value":0},{"name":"self_contained","value":0},{"name":"return_freight_payer","value":0},{"name":"free_sf","value":0},{"name":"duoduo_wholesale","value":0},{"name":"support_nationwide_warranty","value":0},{"name":"only_support_replace","value":0},{"name":"oversea_tracing","value":0},{"name":"distributional_sale","value":0},{"name":"open_in_festival","value":0},{"name":"same_city_distribution","value":0},{"name":"region_black_delay_shipping","value":0},{"name":"has_subsidy_postage","value":0},{"name":"has_sf_express_service","value":0},{"name":"community_group","value":0},{"name":"has_ship_additional","value":0},{"name":"ship_additional_order","value":0}],"is_lucky_flag":1,"yyps_time":"","mkt_biz_type":0,"shipping_type":0,"remark":"","pre_sale_time":"","inner_transaction_id":"","order_change_amount":0.0,"only_support_replace":0,"logistics_id":0,"updated_at":"2022-06-09 14:37:33","street":"","receiver_name_mask":"","receiver_name":"","tracking_number":"","pay_type":"","duoduo_wholesale":0,"buyer_memo":"","is_pre_sale":0,"shipping_time":"","home_delivery_type":0,"after_sales_status":0,"address":"","id_card_name":"","self_contained":0,"goods_amount":1.0,"pay_amount":1.0,"seller_discount":0.0,"address_mask":"","yyps_date":"","confirm_status":1,"confirm_time":"2022-06-09 14:37:23","stock_out_handle_status":-1,"postage":0.0,"province_id":0,"cat_id_3":9056,"cat_id_4":0,"cat_id_1":8726,"receiver_address":"","cat_id_2":8786,"trade_type":0,"urge_shipping_time":"","receiver_phone":"$3MpaxbKBnse9$AgAAAAF2+qYGan7+ggANYOk6e6B2tcD3m4NUAgu6bY4=$0$$","order_sn":"220609-635730697112661"}}} * * 注:虚拟订单充值手机号信息无法通过此接口获取,请联系虚拟类目运营人员。 * @param unknown $order_sn * @return boolean|mixed */ public function getOrderInformation($order_sn) { $params = $this->getPublicParams(); $params['type'] = 'pdd.order.information.get'; $params['order_sn'] = $order_sn; $params['sign'] = $this->getSignature($params); return $this->postRequest(json_encode($params)); } // /** // * 商品明细 // * https://open.pinduoduo.com/application/document/api?id=pdd.goods.detail.get // * // * @param unknown $goods_id 商品id // * // */ // public function getGoodsDetailInfo($goods_id) { // $params = $this->getPublicParams(); // $params['type'] = 'pdd.goods.detail.get'; // $params['goods_id'] = $goods_id; // $params['sign'] = $this->getSignature($params); // return $this->postRequest(json_encode($params)); // } /** * 商品详情接口 * https://open.pinduoduo.com/application/document/api?id=pdd.goods.information.get * * @param unknown $goods_id * * {"goods_info_get_response":{"goods_info":{"goods_name":"万方查重万方数据官网本科硕士博士毕业论文查重论文检测系统2.0","last_category":"论文检测与查询","image_url":"","shipment_limit_second":"172800","goods_quantity":422621,"goods_id":"329073140054","goods_sn":"329073140054","goods_category":"教育培训","is_onsale":"1","is_refundable":"0","second_hand":0,"sku_list":[{"single_price":"3.35","sku_img":"https://img.pddpic.com/mms-material-img/2022-02-27/3622095f-10d0-4a3f-9a2c-51aaa811e08c.png.a.jpeg","outer_goods_id":"","is_sku_onsale":"1","sku_id":"1106921187393","group_price":"2.35","outer_id":"","spec":"保证正品支持真伪验证","sku_quantity":"0"},{"single_price":"30.00","sku_img":"https://img.pddpic.com/mms-material-img/2022-02-27/12c136b0-e0be-4508-91c6-cb2ded66aa5f.png.a.jpeg","outer_goods_id":"","is_sku_onsale":"1","sku_id":"1115835177591","group_price":"25.00","outer_id":"","spec":"万方本科版(高校大学生毕业论文检测)","sku_quantity":"21509"},{"single_price":"30.00","sku_img":"https://img.pddpic.com/mms-material-img/2022-02-27/549d0277-1835-41f9-b9f7-320f6591b9ea.png.a.jpeg","outer_goods_id":"","is_sku_onsale":"1","sku_id":"1115835177592","group_price":"25.00","outer_id":"","spec":"万方硕博版(高校硕博研究生论文检测)","sku_quantity":"21538"},{"single_price":"3.60","sku_img":"https://img.pddpic.com/mms-material-img/2022-02-27/45e5a82b-4921-4686-98c6-2badf65a2789.png.a.jpeg","outer_goods_id":"","is_sku_onsale":"1","sku_id":"1119777051922","group_price":"2.60","outer_id":"","spec":"万方通用版(期刊作业报告等)","sku_quantity":"54166"},{"single_price":"6.00","sku_img":"https://img.pddpic.com/mms-material-img/2022-02-27/d21eb099-7318-432e-9303-fdb861b6e2ba.png.a.jpeg","outer_goods_id":"","is_sku_onsale":"1","sku_id":"1119949041761","group_price":"5.00","outer_id":"","spec":"万方职称版(已发表职称评定检测)","sku_quantity":"325408"}],"goods_type":"1","group_required_customer_num":"2"},"request_id":"16547602950483034"}} */ public function getGoodsInformation($goods_id) { $params = $this->getPublicParams(); $params['type'] = 'pdd.goods.information.get'; $params['goods_id'] = $goods_id; $params['sign'] = $this->getSignature($params); return $this->postRequest(json_encode($params)); } /** * * 商品名称模糊查询 * * 商品列表接口 * https://open.pinduoduo.com/application/document/api?id=pdd.goods.list.get * {"goods_list_get_response":{"goods_list":[{"is_more_sku":1,"goods_name":"checkpass论文查重无限次数低价免注册查重","thumb_url":"https://img.pddpic.com/gaudit-image/2022-03-28/edac0af376a509b227714488bd5dfa37.jpeg","goods_reserve_quantity":0,"image_url":"","sku_list":[{"outer_goods_id":"","is_sku_onsale":1,"reserve_quantity":0,"sku_id":1115504481445,"outer_id":"","spec":"千字符","sku_quantity":1277},{"outer_goods_id":"","is_sku_onsale":1,"reserve_quantity":0,"sku_id":1115476736663,"outer_id":"","spec":"无限次数","sku_quantity":1495}],"goods_quantity":2772,"goods_id":329073007863,"is_onsale":1}],"total_count":1,"request_id":"16551061312578732"}} * * @param unknown $goods_name * @param unknown $outer_goods_id 商家外部商品编码,支持多个,用逗号隔开,最多10个 * @param number $page 返回页码 默认 1,页码从 1 开始PS:当前采用分页返回,数量和页数会一起传,如果不传,则采用 默认值 * @param number $page_size 返回数量,默认 100,最大100。 * @return boolean|mixed */ public function getGoodsList($goods_name='', $outer_goods_id='', $page=1, $page_size=100) { $params = $this->getPublicParams(); $params['type'] = 'pdd.goods.list.get'; if ($goods_name) $params['goods_name'] = $goods_name; if ($outer_goods_id) $params['outer_goods_id'] = $outer_goods_id; $params['page'] = $page; $params['page_size'] = $page_size; $params['sign'] = $this->getSignature($params); return $this->postRequest(json_encode($params)); } /** * 批量获取订单状态 * * * 订单状态 * https://open.pinduoduo.com/application/document/api?id=pdd.order.status.get * {"order_status_get_response":{"request_id":"16552754937789430","order_status_list":[{"order_status":2,"refund_status":4,"orderSn":"220614-336705627082662"},{"order_status":1,"refund_status":4,"orderSn":"220614-170641387082662"},{"order_status":1,"refund_status":4,"orderSn":"220614-321700576842662"}]}} * * @param unknown $order_sns 0150909-452750051,20150909-452750134 用逗号分开 * @return boolean|mixed */ public function getOrderStatus($order_sns) { $params = $this->getPublicParams(); $params['type'] = 'pdd.order.status.get'; $params['order_sns'] = $order_sns; $params['sign'] = $this->getSignature($params); return $this->postRequest(json_encode($params)); } /** * 订单列表查询接口(根据成交时间) * https://open.pinduoduo.com/application/document/api?id=pdd.order.list.get * * @param unknown $start_confirm_at 必填,成交时间开始时间的时间戳,指格林威治时间 1970 年 01 月 01 日 00 时 00 分 00 秒(北京时间 1970 年 01 月 01 日 08 时 00 分 00 秒)起至现在的总秒数 * @param unknown $end_confirm_at 必填,成交时间结束时间的时间戳,指格林威治时间 1970 年 01 月 01 日 00 时 00 分 00 秒(北京时间 1970 年 01 月 01 日 08 时 00 分 00 秒)起至现在的总秒数 PS:开始时间结束时间间距不超过 24 小时 * @param unknown $order_status 发货状态,1:待发货,2:已发货待签收,3:已签收 5:全部 * @param unknown $page 返回页码 默认 1,页码从 1 开始 PS:当前采用分页返回,数量和页数会一起传,如果不传,则采用 默认值 * @param unknown $page_size 返回数量,默认 100。最大 100 * @param unknown $refund_status 售后状态 1:无售后或售后关闭,2:售后处理中,3:退款中,4: 退款成功 5:全部 * @param unknown $trade_type 非必填 订单类型 0-普通订单 ,1- 定金订单 * @param unknown $use_has_next 非必填 是否启用has_next的分页方式,如果指定true,则返回的结果中不包含总记录数,但是会新增一个是否存在下一页的的字段,通过此种方式获取增量交易,效率在原有的基础上有80%的提升 * @return boolean|mixed * * {"error_response":{"error_msg":"access_token已过期","sub_msg":"access_token已过期","sub_code":"10019","error_code":10019,"request_id":"16570185181360686"}} * {"order_list_get_response":{"total_count":1,"has_next":false,"order_list":[{"support_nationwide_warranty":0,"country":"中国","group_status":1,"free_sf":0,"discount_amount":0.0,"platform_discount":0.0,"return_freight_payer":0,"order_status":1,"id_card_num":"","risk_control_status":0,"province":"","town_id":0,"item_list":[{"goods_name":"checkpass论文查重无限次数低价免注册查重","outer_goods_id":"","goods_price":2.0,"goods_id":329073007863,"sku_id":1115504481445,"goods_count":1,"goods_spec":"千字符","outer_id":"","goods_img":"https://img.pddpic.com/mms-material-img/2022-03-28/0c075d33-b036-46f7-a0bf-d40774f68190.png.a.jpeg"}],"pay_no":"","last_ship_time":"2022-07-07 18:59:01","delivery_one_day":0,"created_time":"2022-07-05 18:58:41","card_info_list":[],"refund_status":1,"town":"","is_stock_out":0,"receiver_address_mask":"","receive_time":"","pay_time":"2022-07-05 18:59:01","gift_list":[],"capital_free_discount":0.0,"receiver_phone_mask":"13*******67","country_id":0,"city_id":0,"invoice_status":0,"service_fee_detail":[],"city":"","order_tag_list":[{"name":"delivery_one_day","value":0},{"name":"no_trace_delivery","value":0},{"name":"self_contained","value":0},{"name":"return_freight_payer","value":0},{"name":"free_sf","value":0},{"name":"duoduo_wholesale","value":0},{"name":"support_nationwide_warranty","value":0},{"name":"only_support_replace","value":0},{"name":"oversea_tracing","value":0},{"name":"distributional_sale","value":0},{"name":"open_in_festival","value":0},{"name":"same_city_distribution","value":0},{"name":"region_black_delay_shipping","value":0},{"name":"has_subsidy_postage","value":0},{"name":"has_sf_express_service","value":0},{"name":"community_group","value":0},{"name":"has_ship_additional","value":0},{"name":"ship_additional_order","value":0},{"name":"conso_order","value":0}],"is_lucky_flag":1,"yyps_time":"","mkt_biz_type":0,"shipping_type":0,"remark":"","pre_sale_time":"","inner_transaction_id":"","order_change_amount":0.0,"only_support_replace":0,"logistics_id":0,"updated_at":"2022-07-05 18:59:11","street":"","receiver_name_mask":"","receiver_name":"","tracking_number":"","pay_type":"","duoduo_wholesale":0,"buyer_memo":"","is_pre_sale":0,"shipping_time":"","home_delivery_type":0,"after_sales_status":0,"address":"","id_card_name":"","self_contained":0,"goods_amount":2.0,"pay_amount":2.0,"seller_discount":0.0,"address_mask":"","yyps_date":"","confirm_status":1,"confirm_time":"2022-07-05 18:59:01","stock_out_handle_status":-1,"postage":0.0,"province_id":0,"cat_id_3":9056,"cat_id_4":0,"cat_id_1":8726,"receiver_address":"","cat_id_2":8786,"trade_type":0,"urge_shipping_time":"","receiver_phone":"$u9upNmQ5775n$AgAAAAGFtKUGQpF/UwCIGc9XLGYcE0AFeoGvJNLo1wk=$0$$","order_sn":"220705-189933833112661"}],"request_id":"16570188342965892"}} */ public function getOrderList($start_confirm_at, $end_confirm_at, $order_status, $refund_status, $page, $page_size, $trade_type=-1, $use_has_next='true') { $params = $this->getPublicParams(); $params['type'] = 'pdd.order.list.get'; $params['start_confirm_at'] = $start_confirm_at; $params['end_confirm_at'] = $end_confirm_at; $params['order_status'] = $order_status; $params['refund_status'] = $refund_status; $params['page'] = $page; $params['page_size'] = $page_size; $params['use_has_next'] = $use_has_next; if ($trade_type > -1) $params['trade_type'] = $trade_type; $params['sign'] = $this->getSignature($params); return $this->postRequest(json_encode($params)); } /** * 订单增量接口 * https://open.pinduoduo.com/application/document/api?id=pdd.order.number.list.increment.get * * @param unknown $start_updated_at 必填,最后更新时间开始时间的时间戳,指格林威治时间 1970 年01 月 01 日 00 时 00 分 00 秒(北京时间 1970 年 01 月 01 日 08 时 00 分 00 秒)起至现在的总秒数 * @param unknown $end_updated_at 必填,最后更新时间结束时间的时间戳,指格林威治时间 1970 年 01 月 01 日 00 时 00 分 00 秒(北京时间 1970 年 01 月 01 日 08 时 00 分 00 秒)起至现在的总秒数 PS:开始时间结束时间间距不超过 30 分钟 * @param unknown $order_status 发货状态,1:待发货,2:已发货待签收,3:已签收 5:全部 * @param unknown $page 返回页码,默认 1,页码从 1 开始 PS:当前采用分页返回,数量和页数会一起传,如果不传,则采用 默认值;注:必须采用倒序的分页方式(从最后一页往回取)才能避免漏单问题。 * @param unknown $page_size 返回数量,默认 100。最大 100 * @param unknown $refund_status 售后状态 1:无售后或售后关闭,2:售后处理中,3:退款中,4: 退款成功 5:全部 * @param unknown $is_lucky_flag 订单类型(是否抽奖订单),0-全部,1-非抽奖订单,2-抽奖订单 * @param unknown $trade_type 非必填 订单类型 0-普通订单 ,1- 定金订单 * @param unknown $use_has_next 非必填 是否启用has_next的分页方式,如果指定true,则返回的结果中不包含总记录数,但是会新增一个是否存在下一页的的字段,通过此种方式获取增量交易,效率在原有的基础上有80%的提升 * @return boolean|mixed * * {"error_response":{"error_msg":"access_token已过期","sub_msg":"access_token已过期","sub_code":"10019","error_code":10019,"request_id":"16570185181360686"}} * {"order_list_get_response":{"total_count":1,"has_next":false,"order_list":[{"support_nationwide_warranty":0,"country":"中国","group_status":1,"free_sf":0,"discount_amount":0.0,"platform_discount":0.0,"return_freight_payer":0,"order_status":1,"id_card_num":"","risk_control_status":0,"province":"","town_id":0,"item_list":[{"goods_name":"checkpass论文查重无限次数低价免注册查重","outer_goods_id":"","goods_price":2.0,"goods_id":329073007863,"sku_id":1115504481445,"goods_count":1,"goods_spec":"千字符","outer_id":"","goods_img":"https://img.pddpic.com/mms-material-img/2022-03-28/0c075d33-b036-46f7-a0bf-d40774f68190.png.a.jpeg"}],"pay_no":"","last_ship_time":"2022-07-07 18:59:01","delivery_one_day":0,"created_time":"2022-07-05 18:58:41","card_info_list":[],"refund_status":1,"town":"","is_stock_out":0,"receiver_address_mask":"","receive_time":"","pay_time":"2022-07-05 18:59:01","gift_list":[],"capital_free_discount":0.0,"receiver_phone_mask":"13*******67","country_id":0,"city_id":0,"invoice_status":0,"service_fee_detail":[],"city":"","order_tag_list":[{"name":"delivery_one_day","value":0},{"name":"no_trace_delivery","value":0},{"name":"self_contained","value":0},{"name":"return_freight_payer","value":0},{"name":"free_sf","value":0},{"name":"duoduo_wholesale","value":0},{"name":"support_nationwide_warranty","value":0},{"name":"only_support_replace","value":0},{"name":"oversea_tracing","value":0},{"name":"distributional_sale","value":0},{"name":"open_in_festival","value":0},{"name":"same_city_distribution","value":0},{"name":"region_black_delay_shipping","value":0},{"name":"has_subsidy_postage","value":0},{"name":"has_sf_express_service","value":0},{"name":"community_group","value":0},{"name":"has_ship_additional","value":0},{"name":"ship_additional_order","value":0},{"name":"conso_order","value":0}],"is_lucky_flag":1,"yyps_time":"","mkt_biz_type":0,"shipping_type":0,"remark":"","pre_sale_time":"","inner_transaction_id":"","order_change_amount":0.0,"only_support_replace":0,"logistics_id":0,"updated_at":"2022-07-05 18:59:11","street":"","receiver_name_mask":"","receiver_name":"","tracking_number":"","pay_type":"","duoduo_wholesale":0,"buyer_memo":"","is_pre_sale":0,"shipping_time":"","home_delivery_type":0,"after_sales_status":0,"address":"","id_card_name":"","self_contained":0,"goods_amount":2.0,"pay_amount":2.0,"seller_discount":0.0,"address_mask":"","yyps_date":"","confirm_status":1,"confirm_time":"2022-07-05 18:59:01","stock_out_handle_status":-1,"postage":0.0,"province_id":0,"cat_id_3":9056,"cat_id_4":0,"cat_id_1":8726,"receiver_address":"","cat_id_2":8786,"trade_type":0,"urge_shipping_time":"","receiver_phone":"$u9upNmQ5775n$AgAAAAGFtKUGQpF/UwCIGc9XLGYcE0AFeoGvJNLo1wk=$0$$","order_sn":"220705-189933833112661"}],"request_id":"16570188342965892"}} */ public function getIncrementOrderNumberList($start_updated_at, $end_updated_at, $order_status, $refund_status, $page, $page_size, $is_lucky_flag=0, $trade_type=-1, $use_has_next='true') { $params = $this->getPublicParams(); $params['type'] = 'pdd.order.number.list.increment.get'; $params['start_updated_at'] = $start_updated_at; $params['end_updated_at'] = $end_updated_at; $params['order_status'] = $order_status; $params['refund_status'] = $refund_status; $params['page'] = $page; $params['page_size'] = $page_size; $params['use_has_next'] = $use_has_next; $params['is_lucky_flag'] = $is_lucky_flag; if ($trade_type > -1) $params['trade_type'] = $trade_type; $params['sign'] = $this->getSignature($params); return $this->postRequest(json_encode($params)); } /** * 获取开通订单同步服务的用户 * https://open.pinduoduo.com/application/document/api?id=pdd.ddy.pdp.users.get * * @param string $owner_id 如果传了owner_id,表示单条查询 * @param string $start_modified 查询最后更改时间在某个时间段内的用户 * @param string $end_modified 查询最后更改时间在某个时间段内的用户 * @param number $page_no 当前页数 * @param number $page_size 每页记录数,默认200,最大200 * @return boolean|mixed * * {"ddy_pdp_users_get_response":{"request_id":"16602046604027416","users":[],"total_results":0}} * * {"ddy_pdp_users_get_response":{"request_id":"16602031726529724","users":[{"owner_id":959603435,"rds_id":"48B26FD166F024F7","history_days":0,"status":1}],"total_results":1}} */ public function getDdyPdpUsers($owner_id='', $start_modified='', $end_modified='', $page_no=1, $page_size=200) { $params['type'] = 'pdd.ddy.pdp.users.get'; if ($owner_id) $params['owner_id'] = $owner_id; if ($start_modified) $params['start_modified'] = $start_modified; if ($end_modified) $params['end_modified'] = $end_modified; if ($page_no) $params['page_no'] = $page_no; if ($page_size) $params['page_size'] = $page_size; return $this->getPostRequestResult($params); } /** * 添加数据推送用户 * https://open.pinduoduo.com/application/document/api?id=pdd.ddy.pdp.user.add * * @param unknown $rds_id rds实例编号 * @param unknown $history_days 推送历史数据天数,只能为30天内,包含30天。当此参数不填时,表示以页面中应用配置的历史天数为准;如果为0表示这个用户不推送历史数据;其它表示推送的历史天数 * * {"ddy_pdp_user_add_response":{"is_success":true,"request_id":"16602048767776597"}} * */ public function addDdyPdpUser($rds_id, $history_days=-1) { $params['type'] = 'pdd.ddy.pdp.user.add'; $params['rds_id'] = $rds_id; $params['history_days'] = $history_days; return $this->getPostRequestResult($params); } /** * 删除数据推送用户 * https://open.pinduoduo.com/application/document/api?id=pdd.ddy.pdp.user.delete * * @param unknown $owner_id * @return boolean|mixed */ public function deleteDdyPdpUser($owner_id) { $params['type'] = 'pdd.ddy.pdp.user.delete'; $params['$owner_id'] = $owner_id; return $this->getPostRequestResult($params); } private function getPostRequestResult($params) { $pub_params = $this->getPublicParams(); $nparams = array_merge($pub_params, $params); $nparams['sign'] = $this->getSignature($nparams); return $this->postRequest(json_encode($nparams)); } /** * 公共参数 */ public function getPublicParams() { $pub_params = array( 'client_id' => $this->client_id, 'timestamp' => time(), 'data_type' => $this->data_type, 'version' => $this->version, ); if ($this->access_token) $pub_params['access_token'] = $this->access_token; return $pub_params; } /** * 签名 * https://open.pinduoduo.com/application/document/browse?idStr=8EC06C399636041E * @param unknown $params */ public function getSignature($params) { ksort($params); $signstr = ''; foreach($params as $key => $val) { $signstr .= "{$key}{$val}"; } $signstr = $this->client_secret.$signstr.$this->client_secret; $sign = strtoupper(md5($signstr)); return $sign; } /** * POST REQUEST * @param unknown $url * @param unknown $data * @param array $headers * @param number $timeout */ public function postRequest($data) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->request_headers); //分析是否开启SSL加密 $ssl = substr($this->request_url, 0, 8) == 'https://' ? true : false; if ($ssl) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); // 从证书中检查SSL加密算法是否存在 } curl_setopt($ch, CURLOPT_URL, $this->request_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_TIMEOUT, $this->request_timeout); $res = curl_exec($ch); if(curl_error($ch)=='') { curl_close($ch); return $res; } curl_close($ch); return false; } }