cURL shows blank page

curl return empty response
php curl returns empty string
curl_exec returns nothing
curl returns nothing
curl http info
php curl debug
php curl ssl_verify_result
php curl get url

my curl code show me a blank page

 <?
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL,"http://mysite/scripts/showsomething.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
$core = explode('<!--- BEGIN -->', $result); 
$main = explode('<!--- END -->', $core[1]);
echo $main[0]; 
?>

this code works fine on localhost, but not on server...

There can be several reasons behind your problem.

1) Change <? into <?php and see whether it works or not.

2) For a short test, run this code from your server and check whether it shows you the output or not.

<?php
  echo "sabuj";
?>

3) Some site seek for useragent string on their website request. When they found no useragent, they use to return blank page. You can overcome this with setting an useragent like below.

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0');

4) Another thing you can do is, access the server with ssh client(if you have any) and run the url with wget tool and see whether you can download your page or not.

wget "http://yoursite/page/blabla/...php"

5) Finally, run your curl code with verbose mode enabled. It will help you to debug your curl requests.

curl_setopt($ch, CURLOPT_VERBOSE,true);

CURL returns blank page - PHP, Hi Guys, I have the following script. I am trying to integrate with Google Checkout, but it just returns a blank page. I have checked, double checked and triple  Hi Guys, I have the following script. I am trying to integrate with Google Checkout, but it just returns a blank page. I have checked, double checked and triple checked all the information being

Working Code...

       $ch = curl_init();
       $timeout = 10;
       curl_setopt($ch, CURLOPT_URL, $url);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
       $data = curl_exec($ch);
       curl_close($ch);
       var_dump($data);

Hope it helps...

cURL always return blank page on NGINX PHP, cURL always return blank page on NGINX PHP. Posted March 1 If you find them useful, show some love by clicking the heart. If you run into  Curl supports encrypted fetches when built to use a TLS library and it can be built to use one out of a fairly large set of libraries - "curl -V" will show which one your curl was built to use (if any!). To get a page from a HTTPS server, simply run curl like: curl https://secure.example.com 10.2 Certificates

Turn your error reporting all the way to 11.

error_reporting(E_ALL);

This will tell you a little more about the issue you are facing. The most common culprit when working with curl on a dev environment and moving to a server is a missing curl package.

You can check to see if you have curl installed by doing the following:

if(!function_exists('curl_version')) {
    throw new Exception('Curl package missing');
}

Thus "PHP Fatal error: Call to undefined function curl_init() in..." is a very common error that is thrown.

Some additional debugging tips are to..

  1. print_r the response of curl_exec($handle);
  2. print_r curl_error($handle) this will give you a curl error code.
  3. setup a curl proxy using set_opt and CURLOPT_PROXY, set the value to your ip:port, open the port 8888 on your router and install charles proxy. This will show you an exact printout of the request and response.

Fix the cURL, Fix the cURL - Blank Response Issue, how to fix the issue when cUrl not giving any response. or not on your server. For this copy and paste below code on your page :- response show you the actual error code of cUrl. curl is a tool to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE). The command is designed to work without user interaction.

I've read the previous answers and it seems that your code is fine but problem is connectivity to remote server, please try this:

<?
//debug
error_reporting(E_ALL);
ini_set('display_errors', 1);
//debug end

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL,"http://mysite/scripts/showsomething.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
echo result;
?>

what does it output ?

Notes:

Do you administer the other server? if not, is there a possibility that your ip was blocked by the remote server? Does script http://mysite/scripts/showsomething.php contains any errors ? If you're able to edit it, please enable php errors on showsomething.php by adding the following code at the top of it :

error_reporting(E_ALL);
ini_set('display_errors', 1);

cURL returning blank page - PHP Coding Help, php $Url = "http://www.mysimplehtmlsite.ca"; function DownloadUrl($Url){ // create a new curl resource $ch = curl_init(); curl_setopt($ch,  curl displays this data to the terminal by default, so if you invoke curl to do an operation and it is about to write data to the terminal, it disables the progress meter as otherwise it would mess up the output mixing progress meter and response data. If you want a progress meter for HTTP POST or PUT requests,

php, but this returns the exactly same thing: a blank page. I have cURL installed and the code works for some other sites i tried. I could give you the  There can be several reasons behind your problem. 1) Change <? into <?php and see whether it works or not.. 2) For a short test, run this code from your server and check whether it shows you the output or not.

file_get_contents and cURL returns blank pages : PHPhelp, file_get_contents and cURL returns blank pages. file_get_contents and the page still came back as blank. But when i receive a mail it shows YYYY/MM/DD​. The Linux curl command can do a whole lot more than download files. Find out what curl is capable of, and when you should use it instead of wget. People often struggle to identify the relative strengths of the wget and curl commands. The commands do have some functional overlap. They can each retrieve files from remote locations, but that’s

Curl Response Blank in Laravel, Hi I am getting empty curl response in laravel but when i tried in postman i am getting valid response. Here is my code $ch = curl_init(); $url  There's no use for a password on the -u switch, but a blank one will make curl ask for one and you already entered the real password to kinit/kauth.

Comments
  • Do you administer the other server? if not, is there a possibility that your ip was blocked by the remote server?
  • i don't know if you server support php short tag <? . Please check else try using <?php
  • i use echo curl_getinfo($ch) . '<br/>'; echo curl_errno($ch) . '<br/>'; echo curl_error($ch) . '<br/>'; and get Array 7 couldn't connect to host
  • @user3175158 did you user any valid URL in place of $url?
  • @user3175158 if its working with google. then there must be a problem with the url. The code is working just fine..
  • Change your url out for the google home page. 'google.com' add the following line. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); If you still cannot connect to host you have a networking issue. ie a firewall preventing the connection.
  • if you copy and past the url from your php code can you reach it in a browser as well as ping it from the php server?