XML : how to use shopify api php

Hey i am new in shopify and i have create new private app in my store.i want to use shopify api in my php program.i have write following code in my php file.

Code:

  <?php      $API_KEY = 'XXX';      $SECRET = 'XXX';      $STORE_URL = 'XXX';      $PRODUCT_ID = 'XXX';        $url = 'https://' . $API_KEY . ':' . md5($SECRET) . '@' . $STORE_URL . '/admin/products/' . $PRODUCT_ID . '.xml';        $session = curl_init();      curl_setopt($session, CURLOPT_URL, $url);      curl_setopt($session, CURLOPT_HTTPGET, 1);      curl_setopt($session, CURLOPT_HEADER, false);      curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/xml', 'Content-Type: application/xml'));        curl_setopt($session, CURLOPT_RETURNTRANSFER, true);      $response = curl_exec($session);      curl_close($session);      $product_xml = new SimpleXMLElement($response);       echo $product_xml->title;      echo $product_xml->variants->variant->{'inventory-quantity'};  ?>    

i got the following error.

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in index.php on line 24

Exception: String could not be parsed as XML in C:\wamp\www\apis\index.php on line 24

please help me to short out this problem as soon as possible.please please... thanks in advance.

No comments:

Post a Comment