Jump to content

Recommended Posts

Hi

I am working on amazon and what they are doing is if i am doing any request in curl then they are sending the response as chunked data.

 

Now my problem is how i will read this data. I can read this data but not able to completely parse it.. 

 

This is my code :

 

$ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url); // set URL

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return result in a variable 

    curl_setopt($ch, CURLOPT_HEADER, 1);  // include headers in result

    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheaders); // send my headers     

    $result = curl_exec($ch);

    //get the default response headers

    $headers = curl_getinfo($ch);

    //print_r($headers);

    curl_close($ch);

 

and this is my response

 

HTTP/1.1 200 OK

x-amzn-request-id: a77f37e2-2247-4aba-8d39-54da9e831ea6

Content-Type: application/octet-stream

Transfer-Encoding: chunked

Date: Fri, 26 Oct 2007 17:46:24 GMT

Server: MFA Query Service

 

and this is the actual content what i am trying to filter :

 

order-id order-item-id purchase-date payments-date buyer-email buyer-name buyer-phone-number sku product-name quantity-purchased currency item-price item-tax shipping-price shipping-tax ship-service-level recipient-name ship-address-1 ship-address-2 ship-address-3 ship-city ship-state ship-postal-code ship-country ship-phone-number delivery-start-date delivery-end-date delivery-time-zone delivery-Instructions

203-7894296-3757945 07802496435979 2007-10-25T06:46:25-07:00 2007-10-25T06:46:25-07:00 dead@btinternet.com simon brown 02082913628 B000T5N0JE Advanced Mouse Trap 3 GBP 5.85 0.00 5.50 0.00 Standard simon brown 166 kilmorie road forest hill london london se232sr GB 02082913628

 

 

so i need this content in name->value pair and some where i am doing mistake to read the content properly..

 

Will any one pls guide me what needs to do here?

 

Thanks

Prashant Agarwal

http://prashcom.blogspot.com

 

Link to comment
https://forums.phpfreaks.com/topic/74913-how-to-read-curl-chuncked-response/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.