1$ch = curl_init( $url );
2# Setup request to send json via POST.
3$payload = json_encode( array( "customer"=> $data ) );
4curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
5curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
6# Return response instead of printing.
7curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
8# Send request.
9$result = curl_exec($ch);
10curl_close($ch);
1// set post fields
2$post = [
3 'username' => 'user1',
4 'password' => 'passuser1',
5 'gender' => 1,
6];
7
8$ch = curl_init('http://www.example.com');
9curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
10curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
11
12// execute!
13$response = curl_exec($ch);
14
15// close the connection, release resources used
16curl_close($ch);
17
18// do anything you want with your response
19var_dump($response);