1$post = [
2 'teste' => $_POST['teste']
3];
4httpPost('url.com', $post);
5// function
6function httpPost($url, $data)
7{
8 $curl = curl_init($url);
9 curl_setopt($curl, CURLOPT_POST, true);
10 curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
11 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
12 $response = curl_exec($curl);
13 curl_close($curl);
14 return $response;
15}
1function makeAPICall($url){
2
3
4 $handle = curl_init();
5
6
7 // Set the url
8 curl_setopt($handle, CURLOPT_URL, $url);
9 // Set the result output to be a string.
10 curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
11
12 $output = curl_exec($handle);
13
14 curl_close($handle);
15
16 echo $output;
17 return $output;
18 }
1<?php
2//
3// A very simple PHP example that sends a HTTP POST to a remote site
4//
5
6$ch = curl_init();
7
8curl_setopt($ch, CURLOPT_URL,"http://www.example.com/tester.phtml");
9curl_setopt($ch, CURLOPT_POST, 1);
10curl_setopt($ch, CURLOPT_POSTFIELDS,
11 "postvar1=value1&postvar2=value2&postvar3=value3");
12
13// In real life you should use something like:
14// curl_setopt($ch, CURLOPT_POSTFIELDS,
15// http_build_query(array('postvar1' => 'value1')));
16
17// Receive server response ...
18curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
19
20$server_output = curl_exec($ch);
21
22curl_close ($ch);
23
24// Further processing ...
25if ($server_output == "OK") { ... } else { ... }
26?>