0

php code:

  <?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); 

    ?>

output

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 
                )
            )
        )
    )
)

How could I get the image url and display image on browser

2 Answers 2

1

May be wrong but I guess like this if I look here

echo $xml->product[0]->downloads->images->link;

But if you show us your XML we are more able to help you.

Greets

Sign up to request clarification or add additional context in comments.

Comments

1

I can't test it here. But you can access the tree with:

if you have more products:

<?php
foreach($xml->product as $pout ) {
    echo $pout->downloads->images->link;
}
?>

if you want only one product something like this:

$xml->product[0]->downloads->images->link;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.