ShivaGupta Posted November 30, 2014 Share Posted November 30, 2014 (edited) $post='{"cart_items":[{"configuration":{"price":100,"recharge_number":"9999999999"},"product_id":"999","qty":1}]}'; i try this n reslut was :There are no valid items in cart: help me plz Edited November 30, 2014 by ShivaGupta Quote Link to comment Share on other sites More sharing options...
ShivaGupta Posted November 30, 2014 Author Share Posted November 30, 2014 (edited) Im trying to send a json array to a php post request. {"cart_items":[{"configuration":{"price":100,"recharge_number":"9999999999"},"product_id":"999","qty":1}]} but here i dont know how to send in php plz help me with $fields .its argent url_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); //curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Content-Type: application/json; charset=utf-8")); curl_setopt($ch, CURLOPT_USERAGENT, $agent ); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$fields); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $oone=curl_exec($ch); Edited November 30, 2014 by ShivaGupta Quote Link to comment Share on other sites More sharing options...
Solution QuickOldCar Posted November 30, 2014 Solution Share Posted November 30, 2014 json_decode() Once you have them in an array $fields = http_build_query($json_array); //builds the query this is the count of how many post fields are sending curl_setopt($ch, CURLOPT_POST, count($fields)); 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.