use php to parse json data posted from another php file use php to parse json data posted from another php file curl curl

use php to parse json data posted from another php file


Should not this ?

$posts = array('data'=>$pCon);curl_setopt ($ch, CURLOPT_POSTFIELDS, $posts);

even the example in doc show that

from doc

The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. This can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data. As of PHP 5.2.0, files thats passed to this option with the @ prefix must be in array form to work.

your existing way should work too,

is it possible that $pCon contains some urlencoded values such as =, ? ?


$posts = array('data'=>$pCon);curl_setopt ($ch, CURLOPT_POSTFIELDS, $posts);

this worked.(the person who answered this question deleted the post so i couldnt catch his name, so thankx)

edit:there still was a small error every quote (") was changed to (\") i had a very hard time correcting this so now i am not sending data in json directly but first base64 encode it and when the page receives it , it base64 decodes it. now this workds flawlessly...thankyou all...