+ 1

How to post josn data using php curl

send data to an url

25th Sep 2017, 11:45 AM
Omm Pradhan
Omm Pradhan - avatar
2 odpowiedzi
+ 2
<?php $data = array( "authorizedKey" => "abbad35c5c01-xxxx-xxx", "senderEmail" => "myemail@yahoo.com", "recipientEmail" => "jaketalledo86@yahoo.com", "comment" => "Invitation", "forceDebitCard" => "false" ); $url_send ="http://api.payquicker.com/api/SendInvitation?authorizedKey=xxxxx"; $str_data = json_encode($data); function sendPostData($url, $post){ $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$post); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $result = curl_exec($ch); curl_close($ch); // Seems like good practice return $result; } echo " " . sendPostData($url_send, $str_data); ?>
27th Sep 2017, 7:41 AM
R4xx4r
R4xx4r - avatar
+ 2
bro it's showing error :(
30th Sep 2017, 7:31 AM
Omm Pradhan
Omm Pradhan - avatar