$api_data = array(
'post' => $post
);
$api_data_json = json_encode($api_data);
$base_url = home_url().'wp-json/gic/v1/subscriber';
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $api_data_json);
curl_setopt($curl, CURLOPT_URL, $base_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
if(!$result){die("Connection Failure");}
curl_close($curl);
https://www.weichieprojects.com/blog/curl-api-calls-with-php/
'post' => $post
);
$api_data_json = json_encode($api_data);
$base_url = home_url().'wp-json/gic/v1/subscriber';
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $api_data_json);
curl_setopt($curl, CURLOPT_URL, $base_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
if(!$result){die("Connection Failure");}
curl_close($curl);
https://www.weichieprojects.com/blog/curl-api-calls-with-php/
No comments:
Post a Comment