philsturgeon / codeigniter-curl Goto Github PK
View Code? Open in Web Editor NEWTHIS IS NO LONGER MAINTAINED, USE http://docs.guzzlephp.org INSTEAD
Home Page: http://getsparks.org/packages/curl/show
License: Other
THIS IS NO LONGER MAINTAINED, USE http://docs.guzzlephp.org INSTEAD
Home Page: http://getsparks.org/packages/curl/show
License: Other
If you run the debug() method after a failed curl request, a notice pops up about Curl::$last_response not being defined. I fixed this by just adding a declaration for it in the class definition:
protected $last_response = ''; // Cached response
If I use "simple_get" it doesn't exist, so it hits "__call" but when it tries to invoke the method get (line 62) there is still no "get" method... I see "post" defined. Did this get lost somehow?
Just want to mention that some APIs return error codes 400 or greater. A response message is returned by the API which would be useful, (in this instance the http code was 400 and the error was an xml string), but because of the CURLOPT_FAILONERROR (which defaults to true for simpleget and can not be changed via that call), the response from the curl class is FALSE.
I figured this out pretty quickly and created a custom request:
$this->ci->curl->create($query_string);
$this->ci->curl->option('FAILONERROR', FALSE);
$request = $this->ci->curl->execute();
So that works, and it's simple. This perhaps should be noted in the README, or a second param with options could be available for simple_get.
I just want to mention that when using simple_get with curl options, the second argument must be set to a NULL to indicate that no url parameters in the arguments
$this->curl->simple_get('http://example.com', array(CURLOPT_PORT => 8080));
is erroneous, since it treats the curl options array as $params
the correct one would be...
$this->curl->simple_get('http://example.com', NULL, array(CURLOPT_PORT => 8080));
Hope this should be reflected in the manual...
Hey Phil,
I'm just curious because I haven't seen it before, but what is line #39 in /libraries/Curl.php doing?
Thanks,
Chad
Hey Phil! Love the lib - use it for all my cURL stuffs. :)
Just wanted to point out that when you run:
$this->curl->debug();
The "response" section will always be empty since
$this->set_defaults();
Is always run after closing the connection. Perhaps removing $this->response from the set_default() method would be the best fix? Unless there's a good reason for resetting it for big responses and such.
how to send ip authentication to server
example :
curl -G --user 'api:pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7' -G
https://api.mailgun.net/v3/address/validate
--data-urlencode address='[email protected]'
Tanks
Would u pls add the get requests cache feature? thanks
The execute method sets the CURLOPT_RETURNTRANSFER; for some reason this breaks downloading to files.
This produces a file with 0KB:
$file = fopen($path, 'w');
$this->curl->create($url);
$this->curl->option('file', $file);
$this->curl->execute();
fclose($file);
This works:
$curl = curl_init($url);
$fp = fopen($filename, "w");
curl_setopt($curl, CURLOPT_FILE, $fp);
curl_exec ($curl);
curl_close ($curl);
fclose($fp);
Line 137 is converting the array i pass in to strings.
Which means there's no way to send post request as multipart post?
$get_url = "neo4j_sync/actions.php/coursecluster_includes_course/";
$res = $this->curl->simple_get($get_url, false, array(
CURLOPT_USERAGENT => true,
CURLOPT_TIMEOUT => 0,
CURLOPT_RETURNTRANSFER => true
));
if u see above curl call CURLOPT_TIMEOUT is set to 0 , but im still getting time execution exceeds 300 seceonds error
and even i added " ini_set('max_execution_time', 0); " on top of the code but still facing same issue .. i'm not able to resolve this problem ... please help me out
i confused to send image ?
please help me :(
The PHP-Curl library uses one special escape sequence to send binary files within the posts request.
This '@' character is encoded before submitting the request, then files are sent as a regular POST parameter.
Hi Phil,
Am I doing something wrong or this is issue with lib ?
I'm simply trying to get info from twitter webservice.
Issue is with URL request - it contain my base url which cause 404.
I'm using nginx webserver with php fpm 5.3.6-13ubuntu3.7.
Here is my debug output:
Array
(
[url] => http://localhost:81/index.php/http:twitter.com/statuses/user_timeline/ibmpw.xml
[content_type] => text/html
[http_code] => 404
[header_size] => 154
[request_size] => 110
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.000757
[namelookup_time] => 0.000321
[connect_time] => 0.000481
[pretransfer_time] => 0.000486
[size_upload] => 0
[size_download] => 168
[speed_download] => 221928
[speed_upload] => 0
[download_content_length] => 168
[upload_content_length] => 0
[starttransfer_time] => 0.000725
[redirect_time] => 0
[certinfo] => Array
(
)
[request_header] => GET /index.php/http:twitter.com/statuses/user_timeline/ibmpw.xml HTTP/1.1
Host: localhost:81
Accept: /
)
Thx,
Vukasin
P.S.
Here is my lib call:
autoload.php
$autoload['libraries'] = array('database', 'session','rest');
In controller:
$this->rest->initialize(array('server' => 'http:twitter.com/'));
$tweets = $this->rest->get('statuses/user_timeline/ibmpw.xml');
I am reworking code that initially dealed with curl_* functions directly. Now I want to use this library.
I have got my http-headers for my request prepared as an arrays. But there is no a convenient way (there is no a method) for passing them directly.
Here are my headers:
array(5) { [0]=> string(38) "Content-type: text/xml;charset="utf-8"" [1]=> string(23) "Cache-Control: no-cache" [2]=> string(16) "Pragma: no-cache" [3]=> string(58) "SOAPAction: "http://............"" [4]=> string(22) "Connection: Keep-Alive" }
Here are the options I could use now:
protected $headers = array(); // -- This property is not accessible and it should not be ("ugly hackish way").
public function http_header($header, $content = NULL) // -- This method allows me to pass my headers one by one only. I am forced here to cycle and parse my array of headers.
Is it possible a hew method to be created for adding several headers from an array?
Hello
how can send data in Raw data and header array in post method
https://github.com/php-http/client-common - This is an abstract HTTP client. Guzzle and Curl are implemented as adapters (maybe there are others), they even can be picked up automatically, depending on the server capabilities. Application code does not need to be rewritten when the HTTP-request implementation changes.
Drivers: https://github.com/php-http/curl-client , https://github.com/php-http/guzzle6-adapter
I need to send my user-agent data to include it in the post request
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.