Skip to content

Instantly share code, notes, and snippets.

@FranciscoHV
Created June 9, 2016 16:33
Show Gist options
  • Save FranciscoHV/aa40219ff05dd014730674a2fb7a3aa8 to your computer and use it in GitHub Desktop.
Save FranciscoHV/aa40219ff05dd014730674a2fb7a3aa8 to your computer and use it in GitHub Desktop.
This simple code work fine using libcurl versions before 7.18.x.
<?php
$ch = curl_init("www.example.com/curl.php?option=test");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>
If you have some trouble (Ex.: Failed to open/read local data from file/application) using a similar code with libcurl 7.18.x, try to add the option curl_setopt($ch, CURLOPT_POSTFIELDS, "").
I think there was a change in the option CURLOPT_POST. Now, to use this option, it seems to be necessary to set the option CURLOPT_POSTFIELDS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment