walmart-api产品详细描述被截断

时间:2019-02-28 11:03:04

标签: walmart-api

我可以成功地执行产品搜索,但是我的问题是,有时返回的详细说明不完整,请用短的中间词表示。显然,当说明超过一定大小时。在任何情况下,有时长说明都会被截断,而不是沃尔玛网站上提供的完整说明。 有什么帮助吗? 这是我的代码

$walmart_query =urlencode($search_phrase);
$minprice = ":[".$minprice." TO *]";
$minprice = urlencode($minprice);
$url = 'http://api.walmartlabs.com/v1/search?query='.$walmart_query.'&format=json&categoryId=5428_105913_7662964&apiKey=mykey&IsPublisherId=myid&numItems=25&facet=on&facet.range=price'.$minprice.'';
}
$curl = curl_init();
// Set options
curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $url,
    CURLOPT_CONNECTTIMEOUT => 30,
    CURLOPT_TIMEOUT => 30
));
$response = curl_exec($curl);
curl_close($curl);
$response = json_decode($response, true);
$walmart_total=$response[numItems];

for($i=0;$i<$walmart_total ;$i++){
$walmart_array[$i]['title'] = $response[items][$i][name];   
 $walmart_array[$i]['image'] = $response[items][$i][mediumImage];
 $walmart_array[$i]['image_large'] = $response[items][$i][largeImage];  
 $walmart_array[$i]['merchant'] = "walmart"; 
$walmart_array[$i]['link'] = str_replace('|LSNID|','cKpOH4H0svU',$response[items][$i][productTrackingUrl]);
$walmart_array[$i]['msrp_price'] = $response[items][$i][msrp];
$walmart_array[$i]['description'] = $response[items][$i][longDescription];
$walmart_array[$i]['stock'] = $response[items][$i][stock];
$walmart_array[$i]['rating'] = $response[items][$i][customerRating];
$walmart_array[$i]['brand'] = $response[items][$i][brandName];
$walmart_array[$i]['numreviews'] = $response[items][$i][numReviews];
$walmart_array[$i]['sale_price']=$response[items][$i][salePrice];
if(empty($walmart_array[$i]['msrp_price'])){
    $walmart_array[$i]['price'] = $response[items][$i][salePrice];  
$walmart_array[$i]['sale_price'] = $response[items][$i][salePrice];
$walmart_array[$i]['discount'] =0;
}

0 个答案:

没有答案