首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从amazon产品广告API获取功能

如何从amazon产品广告API获取功能
EN

Stack Overflow用户
提问于 2016-09-29 16:35:30
回答 1查看 596关注 0票数 0

我正在使用亚马逊产品广告API,并使用其ASIN值获取产品详细信息。我正在获取XML格式的数据,但在评估产品的功能时遇到了问题。

代码语言:javascript
运行
复制
<?xml version="1.0"?>
-<ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
+<OperationRequest>
-<Items>
-<Item> 
<ASIN>B01G9VYRWU</ASIN>  
<ParentASIN>B01D4FCID4</ParentASIN>
<DetailPageURL>http://www.amazon.co.uk/Unlocked-Smartphone-Android-MT6580-HotKnot/dp/B01G9VYRWU%3Fpsc%3D1%26SubscriptionId%3DAKIAJVHGJYQC2HPM3LHQ%26tag%3Dhogmall-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB01G9VYRWU</DetailPageURL>
+<ItemLinks>
+<SmallImage>
+<MediumImage>   
+<LargeImage>
+<ImageSets>
-<ItemAttributes>
<Binding>Electronics</Binding>
<Color>Gold</Color> 
<Feature>POWERFUL 4150 mAh BATTERY: Tired of bringing a power bank everywhere? Then enjoy the long battery life of this handset. When you are traveling, using the built-in GPS on Google map is power -hungry. Don't worry about of running out power in outdoor any more. Even heavy user don't need to charge this cell phone everyday!</Feature>

<Feature>3G DUAL SIM SMARTPHONE: 3G: WCDMA 900/1900/2100MHz, also support 2g: GSM 850/900/1800/1900MHz. Compatible with lots of Carriers like Vodafone, O2, EE, T-mobile, Three, giffgaff, Lebara, CTExcelbiz, Lyca, Talk home Mobile......Two micro sim slots allow you to combine both work and personal use on the same handset or use one sim in UK. One slot is for micro sim card, another is for micro sim card or micro SD card up to 32GB of extended storage.</Feature>

<Feature>BUDGET PHONE WITH HIGH TECH SPECIFICATION: It has fast Quad Core 1.3 GHz Processor running on good Android 5.1 Lollipop system, 2GB RAM and 5.5 inch HD screen. Games, apps, web browsing, movies and everything else will run fantastically quickly on Note S.</Feature>

<Feature>COOL CAMERA: With an interpolated 8MP auto focus camera featuring an LED flash and interpolated 5MP wide-angle front camera, you'll have the confidence to capture shots even in challenging conditions. Face front camera let you enjoy video talk on whatsapp, Skype and take great selfies. Experience a crisp and bright viewing experience, even in direct sunlight, with a super sharp 5.5" HD display that sits elegantly in a precision crafted, diamond cut sleek frame.</Feature>

<Feature>SAFE GUARANTEE: Our Cubot smartphones have CE and ROHS certification. All handsets are environmental-friendly.And we offer 1 year guarantee free repair and return for phone itself serious quality problem</Feature>

<Label>CUBOT</Label>
<Manufacturer>CUBOT</Manufacturer>
<Model>166711601</Model>
<MPN>166711601</MPN>
-<PackageDimensions>   
<Height Units="hundredths-inches">291</Height> 
<Length Units="hundredths-inches">732</Length>   
<Weight Units="hundredths-pounds">119</Weight> 
<Width Units="hundredths-inches">441</Width>  
</PackageDimensions>
<PackageQuantity>1</PackageQuantity>
<PartNumber>166711601</PartNumber> 
<ProductGroup>Wireless</ProductGroup> 
<ProductTypeName>PHONE</ProductTypeName> 
<Publisher>CUBOT</Publisher>  
<Studio>CUBOT</Studio> 
<Title>CUBOT NOTE S Unlocked 3G 5.5'' Smartphone Dual Sim Smartphone Android 5.1 MT6580 Quad Core 1.3GHz Mobile Phone 2GB RAM+16GB ROM Dual SIM HotKnot (Gold)</Title>   
</ItemAttributes>
+<OfferSummary>
+<Offers>
</Item>  
</Items>
</ItemLookupResponse>

获取我在下面的代码中使用的特性

代码语言:javascript
运行
复制
$response = simplexml_load_file($request_url);
if(isset($response->Items->Item)){
            echo 'yes';

            //$asin = $response->Items->Item->ASIN;
            if(in_array($id, $json)){ //if id is in features array then continue

                //if(isset($response->Items->Item->ItemAttributes)){
                    echo '<br>Features<br>';
                    foreach($response->Items->Item as $item){
                        foreach($item->ItemAttributes->Feature as $fea){
                            echo 'features '.trim($fea).'<br>';
                            $value = str_replace("'", "%", trim($fea));//replaced " with ! because giving error in sql query
                            $value = str_replace('"', "!", trim($fea));
                            if($value != '' || $value != NULL){
                                $duplicate .= '("'.trim($id).'", "'.trim($asin).'", "'.trim($value).'" ) ,';
                                $sql_features .= '("'.trim($id).'", "'.trim($asin).'", "'.$value.'" ) ,';
                            }

                            echo $sql_features .'<br>';

                        }

                    }
            }

        }

但是我不能得到产品的特性。

EN

回答 1

Stack Overflow用户

发布于 2016-09-29 16:47:08

您的$sql_features变量可能超出范围,请尝试此方法

代码语言:javascript
运行
复制
 if($value != '' || $value != NULL){
   $duplicate .= '("'.trim($id).'", "'.trim($asin).'", "'.trim($value).'" ) ,';
   $sql_features .= '("'.trim($id).'", "'.trim($asin).'", "'.$value.'" ) ,';

   // echo it inside if
   echo $sql_features .'<br>';
   }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39765339

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档