Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The module name is as the name reveals based on the curl library. But it also supports other web-drivers. Besides of this, this module has a small driver for handling basic SOAP-calls. The class itself is called  Tornevall_SimpleSoap, and is initialized automatically when using http-calls with "?wsdl" in the URL. If you think that the tiny parameter "?wsdl" is useless, enforcing the SoapClient during the web-call is possible by using CURLNETCURL_POST_ASDATATYPES::POSTDATATYPE_AS_SOAPJSON, instead of POSTDATATYPE_AS_JSON or similar. More about this, will come.

Note
titleDeprecation of class name Tornevall_cURL

As of v6.0.20, netcurl is splitted up in sections and classes instead of having all source code in one bundled file. The name Tornevall_cURL has been renamed and is from this version deprecated. The new name of all classes is based on MODULE_<name>, meaning Tornevall_cURL is now known as MODULE_CURL. Most of the components are backwards compatible, so using for example CURL_POST_AS instead of the new class NETCURL_POST_DATATYPES still works.

Module initialization

The easiest way to get started with the module is with composer:

...

Code Block
<?php
require_once('vendor/autoload.php');
use \TorneLIB\TornevallMODULE_cURLCURL;

The last usage-row is added to simplify the instance creation of the library. Instead of running

Code Block
new \TorneLIB\TornevallMODULE_cURLCURL();

this makes it possible to just run a

Code Block
new TornevallMODULE_cURLCURL();

Note that if you initialize the module with no constructor arguments, you can set it up more detailed afterwards. The module was, before the chain implementation, built in a way that you in a default state never needed to configure anything, but configuration was available if requirements changed. For example, it was possible to initialize the module and then run more calls after each other, with different settings (i.e. different outgoing ip-interfaces, when there was a need to spread the calls between many hosts). Yes; this is basically a "going under the radar"-function, with spoofability.

...

Code Block
$getIpByJson = (new \TorneLIB\TornevallMODULE_cURLCURL('http://identifier.tornevall.net/?json'))->getParsedResponse>getParsed();

The response of the request should look like something like this:

...

With NetCurl 6.0.18 and newer versions, initializing the library with authenication values is also possible. However, currently, the best supported authentication is CURLAUTH_BASIC (CURLNETCURL_AUTH_TYPES::AUTHTYPE_BASIC), with failover on CURLAUTH_ANY. To use authentication at construction level, one can use something like this:

Code Block
$myWebRequest = (new TornevallMODULE_cURLCURL("https://test.com/get/this/info/with/my/personal/account", array(), CURLNETCURL_POST_METHODS::METHOD_GET, array('auth'=>array('username'=>'username', 'password'=>'password'))))->getParsedResponse>getParsed();

Without this oneliner, the call can also be done with the following code:

Code Block
$regularRequest = new TornevallMODULE_cURLCURL();
$regularRequest->setAuthentication("username", "password");
$chainRequest = $regularRequest->doGet("https://test.com/get/this/info/with/my/personal/account")->getParsedResponse>getParsed();