• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CurlRequest.php Error

#1
I am playing around with CI4 and trying to get the CurlRequest.php library working. I'm following the instructions in the user guide, trying to just get a simple request built but I'm getting the below error. This seems as basic as I can possibly get it, according to the user guide. Am I missing something? Also, I'm using the develop branch at the moment.

Code:
<?php namespace App\Controllers;

class Home extends BaseController
{
    public function index()
    {
        $client = \Config\Services::curlrequest([
           'base_uri' => 'https://example.com/exe',
       ]);

        d($client);

       $response = $client->request('POST', '/hello_world.pf', [
           'form_params' => [
               'name' => 'Andrew'
           ]
       ]);

       d($response);
   }
}


ErrorException

curl_setopt_array(): supplied argument is not a valid File-Handle resource 
Reply

#2
HI there, I'm fairly novice with the cURL library but I'll share my experience.

I also have had this issue. If you go to the System folder of your CI install, HTTP/CURLRequest.php file, and comment out the default debug config, you can work around it.

protected $config = [

'timeout' => 0.0,

'connect_timeout' => 150,

//'debug' => false,

'verify' => true,

];

I've been fighting with the CURLRequest library a fair bit. My hope is that the CI team will elaborate more on CURL and how to get it set up. They Base it on the Guzzle CURL library, but I've had a hard time finding comprehensive documentation on how to make everything work. I'm also having issues as I work through a firewall and not all pages can be requested. And it also seems that many of the pages I'm testing on are set up not to respond to CURL requests so I'm a bit hooped.

Good luck.

Thanks
Reply

#3
(06-27-2019, 08:40 AM)mightyted Wrote: HI there, I'm fairly novice with the cURL library but I'll share my experience.

I also have had this issue. If you go to the System folder of your CI install, HTTP/CURLRequest.php file, and comment out the default debug config, you can work around it.

protected $config = [

'timeout'         => 0.0,

'connect_timeout' => 150,

//'debug'           => false,

'verify'          => true,

];

I've been fighting with the CURLRequest library a fair bit. My hope is that the CI team will elaborate more on CURL and how to get it set up. They Base it on the Guzzle CURL library, but I've had a hard time finding comprehensive documentation on how to make everything work. I'm also having issues as I work through a firewall and not all pages can be requested. And it also seems that many of the pages I'm testing on are set up not to respond to CURL requests so I'm a bit hooped.

Good luck.

Thanks

Thank you so much for your suggestion! Commenting out that bit of code did the trick. 

Have you taken a look at the CI4 User Guide? The information regarding how to actually use the CurlRequest class is pretty detailed.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.