是否正确完成?我仍然对 api 的工作方式感到困惑。我是新手。我已经四处谷歌寻找答案。我按照教程并尝试修改它。这是基本的。
我想检索正在销售(模式=热)的产品图像以进行幻灯片放映。如果您能帮助我了解如何完成 api,我将不胜感激。
编辑 我正在尝试从 pinnacle 购物车中的数据库中提取图像。所以我想列出它在 xml 中的内容。您在下面看到的所有 xml 都在源视图上,但不在网页本身上,这正常吗?此外,当我尝试在网页上显示图像并且图像没有出现时。我不确定我哪里出错了。
<Product>
<Price><![CDATA[695.00000]]></Price>
<Visible><![CDATA[Yes]]></Visible>
<Taxable><![CDATA[Yes]]></Taxable>
<Weight><![CDATA[0.00]]></Weight>
<UPC><![CDATA[]]></UPC>
<Sku><![CDATA[]]></Sku>
<Title><![CDATA[Necklace]]></Title>
<URL><![CDATA[https://xxxxx/staging/index.php?p=product&id=80]]></URL>
<ThumbnailImageUrl><![CDATA[http://www.xxxxxxxxxx.com/staging/images/products/thumbs/100040.jpg]]></ThumbnailImageUrl>
<ImageUrl><![CDATA[http://www.xxxxxxxx.com/staging/images/products/100040.jpg]]></ImageUrl>
<Discontinued><![CDATA[No]]></Discontinued>
<Options> </Options>
<Added><![CDATA[2010-05-12 13:50:00]]></Added>
<ManufaturerName><![CDATA[]]></ManufaturerName>
<Description><![CDATA[<p> </p><p> </p>]]></Description>
<AmazonId><![CDATA[]]></AmazonId>
<AmazonItemCondition><![CDATA[]]></AmazonItemCondition>
<AmazonIdType><![CDATA[]]></AmazonIdType>
<EbayCategoryId><![CDATA[]]></EbayCategoryId>
<YahooPath><![CDATA[]]></YahooPath>
<GoogleItemCondition><![CDATA[]]></GoogleItemCondition>
<PricegrabberCategory><![CDATA[]]></PricegrabberCategory>
<PricegrabberItemCondition><![CDATA[]]></PricegrabberItemCondition>
<PricegrabberPartNumber><![CDATA[]]></PricegrabberPartNumber>
<InventoryControl><![CDATA[Yes]]></InventoryControl>
<PID><![CDATA[80]]></PID>
<ProductId><![CDATA[100040]]></ProductId>
<Qoh><![CDATA[1]]></Qoh>
<NextagCategory><![CDATA[]]></NextagCategory>
<NextagPartNumber><![CDATA[]]></NextagPartNumber>
<NextagItemCondition><![CDATA[]]></NextagItemCondition>
</Product>
我的代码
<?php
$shop='www.xxx.com/staging/content/admin/plugins/openapi/index.php?';
$user = "asd";
$password = "ad";
$token = 'token';
// Assemble the account url
$url = 'https://'.$shop."username=".$user."&password=".$password."&token=".$token. "&apiType=xml&call=GetProducts&mode=hot";
// Setup the cURL object
$curl = curl_init();
curl_setopt($l_oCurl, CURLOPT_POST, 1);
curl_setopt( $curl, CURLOPT_URL, $url );
$response=curl_exec($curl);
curl_close($curl);
$image_xml = new SimpleXMLElement($response);
**foreach($xml->ThumbnailImageUrl as $thumbs){
echo "<img src=".$thumbs."/>";**
}
?>