PHP code example of pilskalns / f3-wcurl
1. Go to this page and download the library: Download pilskalns/f3-wcurl library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pilskalns / f3-wcurl example snippets php
$wcurl = \wcurl::instance([$iniName = 'wcurl' | $optionsArray]);
php
$wcurl->setOptions(
[
'useragent' = > 'F3-wcurl API integration',
'encodeJSON' = > false,
'ttl' = > 300,
// etc
]
);
php
$wcurl->clearOptions([ 'useragent', 'ttl' /*, ... etc */ ]);
php
$wcurl->clearOptions();
php
$wcurl->getStats();
php
$response = $wcurl->get( string $url [, array $fill = null [, array $options = null ]] );
php
$response = $wcurl->post( string $url, array $body = null [, array $fill = null [, array $options = null ]] );
php
$response = $wcurl->put( string $url, array $body = null [, array $fill = null [, array $options = null ]] );
php
$response = $wcurl->patch( string $url, array $body = null [, array $fill = null [, array $options = null ]] );
php
$response = $wcurl->delete( string $url, array $body = null [, array $fill = null [, array $options = null ]] );
php
$wcurl->setOptions(
'rests' => [
'allmembers' => '/lists/members/all/pages',
'withVariable' => '/lists/members/%%memberID%%/pages',
'updateEmail' => '/lists/members/%%memberID%%/update'
]
);
php
$response = $wcurl->get( 'allmembers' );
php
$response = $wcurl->get( 'withVariable', array('memberID' => 'abc123ID') );
php
$wcurl->setLogin( callback 'yourClass::cb_do_login' );
php
static function cb_do_login(){
$wcurl = \wcurl::instance();
$login = $wcurl->post("/login", array(
'login'=> 'my_user',
'password'=> 'covfefe' )
);
if($login['status']['http_code']==200){
return true;
}
// or
$wcurl->setOptions( [ 'basicauth' => "$user:$password"]);
}
php
$apiTwo = new wcurl([$iniName | $optionsArray]);