Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $data = ['data' => 'this', 'data2' => 'that'];
- $headers = [
- 'Accept' => '*/*',
- 'Content-Type' => 'application/x-www-form-urlencoded',
- 'Custom-Header' => 'custom-value',
- 'Custom-Header-Two' => 'custom-value',
- ];
- // open connection
- $ch = curl_init();
- // set curl options
- $options = [
- CURLOPT_URL => $url,
- CURLOPT_POST => count($data),
- CURLOPT_POSTFIELDS => http_build_query($data),
- CURLOPT_HTTPHEADER => $headers,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_FOLLOWLOCATION => false //Sets follow_location to false so the header will be inserted
- ];
- curl_setopt_array($ch, $options);
- // execute
- $result = curl_exec($ch);
- // close connection
- curl_close($ch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement