php代码:
<?php
$url = 'https://www.rudolphs-christmasshop.com.au/api/v2/products/';
$username ='xyz'; $password ='ca25fe6947564b9479sdfsaffsaffasfasfsaffdasfe5866b4';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD,$username . ':' . $password);
$result = curl_exec($ch); curl_close($ch);
$xml = simplexml_load_string($result);
?>
输出
SimpleXMLElement Object (
[product] => Array (
[0] => SimpleXMLElement Object (
[id] => 29
[name] => SimpleXMLElement Object ( )
[type] => physical
[sku] => 22254
[description] => SimpleXMLElement Object ( )
[search_keywords] => SimpleXMLElement Object ( )
[availability_description] => SimpleXMLElement Object ( )
[price] => 22.9500
[inventory_warning_level] => 5
[warranty] => SimpleXMLElement Object ( )
[weight] => 0.2500
[width] => 13.0000
[height] => 11.0000
[depth] => 8.0000
[view_count] => 125
[page_title] => Aussie Koala and Baby Christmas Ornament - Australiana
[meta_keywords] => koala bear decoration, koala christmas ornament, australian decorations, aussie christmas, christmas decoration
[meta_description] => SimpleXMLElement Object ( )
[layout_file] => product.html
[is_price_hidden] => false
[price_hidden_label] => SimpleXMLElement Object ( )
[categories] => SimpleXMLElement Object (
[value] => 30
)
[downloads] => SimpleXMLElement Object (
[link] => /products/29/downloads )
[images] => SimpleXMLElement Object (
[link] => /products/29/images
)
)
)
)
)
如何获取图像 url 并在浏览器上显示图像