Welcome Guest, Not a member yet? Register   Sign In
CURLRequest.php
#1

HI there CI guys. You're all doing a great job and am looking forward to the production product. 

I've been working on some practice projects  and I ran into an issue using cURL. 

My objective is to get the contents of a webpage and extract the title. Whenever I tried to use the cURL library to access an external page I would get the follow error message in my log. 

curl_setopt_array(): cannot represent a stream of type Output as a STDIO FILE*

So I started digging around and I think I discovered what was causing my issue. The issue in the CURLRequest.php file in the function setCURLOptions(). Please see the following section of code currently starting around line 676 of the file. 

  if (isset($config['debug']))
  {
   $curl_options[CURLOPT_VERBOSE] = $config['debug'] === true ? 1 : 0;
   $curl_options[CURLOPT_STDERR]  = is_bool($config['debug']) ? fopen('php://output', 'w+') : $config['debug'];
  }

The problem I'm having is that this runs even when I don't set the debug param in the curl request. See
$response = $client->request('GET', "http://something/something", [
     'auth' => ['user', 'pass']    
     
   ]);

For now I have worked around this by commenting out line 78  where the 'debug' param is set by the class file. See

protected $config = [
  'timeout'         => 0.0,
  'connect_timeout' => 150,
  //'debug'           => false,
  'verify'          => true,
 ];

Another workaround was to change "php://output" to a file location so it doesn't open a stream. 

Anyways, either I am using your cURL library incorrectly or maybe there should be a different way to setting the debug format . 

Any feedback you guys can provide would be helpful. 

Oh and if you have any suggestions on how to use the CI cURL library (based on guzzle) to extract the title out of a webpage. I still haven't figured that out yet.

Cheers all. and thanks for all your hard work.
Reply


Messages In This Thread
CURLRequest.php - by mightyted - 05-08-2019, 08:29 AM
RE: CURLRequest.php - by kilishan - 05-08-2019, 08:43 AM
RE: CURLRequest.php - by mightyted - 05-09-2019, 01:17 PM
RE: CURLRequest.php - by kilishan - 05-09-2019, 08:53 PM
RE: CURLRequest.php - by mightyted - 05-15-2019, 01:04 PM
RE: CURLRequest.php - by mightyted - 05-17-2019, 04:43 PM
RE: CURLRequest.php - by kilishan - 05-17-2019, 08:22 PM
RE: CURLRequest.php - by mightyted - 05-21-2019, 08:02 AM
RE: CURLRequest.php - by mightyted - 05-28-2019, 08:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB