$provinceId, 'cityId' => $cityId, 'countyId' => $countyId, 'townId' => 0, 'skuId' => $skuId, 'skuNum' => $skuNum, ]; //echo 'https://vapi.jd.com/index/sku/getAsynDetail?'.http_build_query($data); //exit(); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://vapi.jd.com/index/sku/getAsynDetail?'.http_build_query($data), CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Host: vapi.jd.com', 'Referer: https://bpro.jd.com/' ), )); $response = curl_exec($curl); curl_close($curl); $res = json_decode($response, true); // echo "
"; // print_r($res); // exit(); if ($res && isset($res['success']) && $res['success'] == 1) { return $res['result']; } return null; } /** * 实时获取商品主图和详情 * [getGoodsMainImageAndDetail description] * @param [type] $skuId [description] * @return [type] [description] */ public function getGoodsMainImageAndDetail($skuId){ //$url = "http://47.98.251.206:8811/api/goods/info/v2?sku=".$skuId."&areaId="; $url = "http://8.130.98.31:8811/api/goods/info/v2?sku=".$skuId."&areaId="; $res = httpRequest($url); if ($res && $res['code'] == 0 && isset($res['data'])) { return $res['data']; } return []; } /** * 获取京东短链接 * [getJdShortLink description] * @param [type] $skuId [description] * @return [type] [description] */ public function getJdShortLink($skuId){ //$url = "http://47.98.251.206:8811/api/goods/info/v2?sku=".$skuId."&areaId="; $url = "http://8.130.98.31:8811/api/link?sku=".$skuId; $res = httpRequest($url); if ($res && $res['code'] == 0 && isset($res['data'])) { return $res['data']; } return ""; } }