Ebay检索特定订单的详细信息
作者:互联网
GetOrder:https://developer.ebay.com/api-docs/sell/fulfillment/resources/order/methods/getOrder
GetOrders:https://developer.ebay.com/api-docs/sell/fulfillment/resources/order/methods/getOrders
/** * @title 检索特定订单的详细信息 * @author 卡卡 */ public function get_order() { $timestamp = time(); $today_start = mktime(0, 0, 0, date("m", $timestamp), date("d", $timestamp), date("Y", $timestamp)); $today_Gmt_day = UnixToGmt("Y-m-d", $today_start); $today_Gmt_hour = UnixToGmt("H:i:s", $today_start); $FilterField = 'creationdate:[' . $today_Gmt_day . 'T' . $today_Gmt_hour . '.000Z]'; # https://api.ebay.com/sell/fulfillment/v1/order/{orderId}?fieldGroups=TAX_BREAKDOWN # 查询所有店铺表 $where['status'] = 1; $store_list = Db::name('store')->where($where)->field('store_id,name,store_code,seller_id,seller_secret,seller_url,access_token,refresh_token')->order('create_time desc')->select(); $order_list = []; foreach ($store_list as $key => $value) { $access_token = $value['access_token']; $sell_AuthToken = sprintf("Authorization: Bearer %s\r\n", $access_token); // GET https://api.ebay.com/sell/fulfillment/v1/order? // orderIds=string& // filter=FilterField& // limit=string& // offset=string& // fieldGroups=string $limit = 1000; $url = "https://api.ebay.com/sell/fulfillment/v1/order?filter=" . $FilterField . "&limit=" . $limit . "&offset=0&fieldGroups=TAX_BREAKDOWN"; # 初始化CURL会话 $connection = curl_init(); # 设置端点网址 curl_setopt($connection, CURLOPT_URL, $url); # 将Method设置为GET; 默认情况下为Get,因此如果呼叫为Get call则不进行设置就可以 curl_setopt($connection, CURLOPT_HTTPGET, true); # 创建标题数组 $headers = array(); $headers[] = $sell_AuthToken; $headers[] = 'X-EBAY-GLOBAL-ID:EBAY-US'; # 使用标题数组设置标题 curl_setopt($connection, CURLOPT_HTTPHEADER, $headers); # 将其设置为从curl_exec以字符串形式返回传输 curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1); # 阻止CURL验证对等方的证书 curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0); # 发送请求 $response = curl_exec($connection); $response = json_decode($response); $response = object_array($response); //关闭连接 curl_close($connection); $response['store_id'] = $value['store_id']; array_push($order_list, $response); } $msg['order_list'] = $order_list; return successJson($msg); }
/** *把时间戳转换为格林威治时间 */ function UnixToGmt($format_string = "Y-m-d H:i:s", $UnixTime = 0) { return @gmdate($format_string, $UnixTime); }
标签:检索,Ebay,connection,today,response,curl,详细信息,order,store 来源: https://www.cnblogs.com/kaka0318/p/14668531.html