Php curl post request7/22/2023 ![]() The file_get_contents() function is used to receive data in a more readable format. ch curlinit( url ) Setup request to send json via POST.Use json_decode() function to decoded JSON data in PHP. ![]() The following example shows how you can get or fetch the JSON POST data using PHP. Set the content type to application/jsonĬurl_setopt ( $ch, CURLOPT_HTTPHEADER , array( 'Content-Type:application/json' )) Ĭurl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ) Ĭurl_close ( $ch ) Receive JSON POST Data using PHP Attach encoded JSON string to the POST fieldsĬurl_setopt ( $ch, CURLOPT_POSTFIELDS, $payload ) $payload = json_encode (array( "user" => $data ))
0 Comments
Leave a Reply. |