Jump to content

How to read Curl Chuncked response


prashcom

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 [email protected] 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.