How to Pass JSON Data in a URL using CURL in PHP?



How to Pass JSON Data in a URL using CURL in PHP?..

Answer / Amit Prasad

To pass JSON data in a URL using CURL in PHP, you can first encode the JSON data as a string, and then use the curl_setopt() function to set the CURLOPT_POSTFIELDS option. Here is an example: `$jsonData = json_encode($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://example.com'); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); ...'

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

how to upload 100mb file using .htaccess..

2 Answers  


Suppose we receive a form submitted by a post to subscribe to a newsletter. This form has only one field, an input text field named email. How would we validate whether the field is empty? Print a message "the email cannot be empty" in this case?

1 Answers  


How to replace a substring in a given string?

1 Answers  


What will the ?getdate() function returns in PHP?

1 Answers  


How many bootable file in O/S - XP,2000, and 98. which are the files.

1 Answers   IBM,


What is mean by RSS?How can i use this?

1 Answers   TCS,


Does php support polymorphism?

1 Answers  


display selected value in dropdown list through javascript without page refresh

5 Answers   ASD Lab,


what is the default session expire time in php? what is default file attachment size in mail in php?

3 Answers  


How can you get, the total size of a certain directory?

1 Answers  


Can constructor be private in php?

1 Answers  


How to access a specific character in a string using php?

1 Answers  


Categories