• 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, 07: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

#4
im having the same issue with a simple post request. editing system file sounds like a terrible idea. hopefully someone has a solution to this.
Reply

#5
(10-01-2019, 10:20 AM)angrymongol Wrote: im having the same issue with a simple post request. editing system file sounds like a terrible idea. hopefully someone has a solution to this.
I agree. My work around was more geared towards finding a solution. I have stopped using the CURL Library until it gets resolved.
Reply

#6
(10-01-2019, 01:18 PM)mightyted Wrote:
(10-01-2019, 10:20 AM)angrymongol Wrote: im having the same issue with a simple post request. editing system file sounds like a terrible idea. hopefully someone has a solution to this.
I agree. My work around was more geared towards finding a solution. I have stopped using the CURL Library until it gets resolved.

I get the distinct impression there is a problem with the PHP Curl source library.

I have a website that checks the http_response_code() and it works well for all URLs except the same website URL? The Curl http_response_code returned is a 404 for the rendered page!

Selecting "Verbose" uses the PHP get_headers($url); which I can only call sequentially and is very slow but gives the correct results - compared to a:

curl_multi_init ( void ) : resource
Allows the processing of multiple cURL handles asynchronously.


Selecting "Demo" from : https://supiet2.tk/test? virtually instantly displays the 112 URL http_response codes:

Rendered 112 URLS:
  2.20 mSecs
  (28 sites x 4 protocols)    



Like yourself I have tried in vain and not been able to resolve the issue.
 
download and make your system directory strict
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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