PHP code example of thinknet / request

1. Go to this page and download the library: Download thinknet/request 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/ */

    

thinknet / request example snippets



    "thinknet/request": "dev-master"



'providers' => array(

    'Thinknet\Request\RequestServiceProvider'

)



'aliases' => array(

    'ThinknetService' => 'Thinknet\Request\Service'

)



SERVICE_BASE_URL=http://www.example.com



use ThinknetService;

class ServiceController extends Controller
{
    protected $service;

    public function __construct(Service $service)
    {
        $this->service = $service;
    }
}



// get : Return this
public function getService()
{
    $this->service->get(url, param);
}

// post : Return this
public function postService()
{
    $this->service->post(url, param);
}

// put : Return this
public function putService()
{
    $this->service->put(url, param);
}

// delete : Return this
public function deleteService()
{
    $this->service->delete(url, param);
}



// getResult : Return Json Obj OR Null
    $this->service->getResult();

// call : Return this
    $this->service->call($url, $method)

// isSuccess : Return Boolean
    $this->service->isSuccess();

// getHttpCode : Return int
    $this->service->getHttpCode();

// setHeader : Return Void
    $this->service->setHeader(key, value);

// addHeader : Return Void
    $this->service->SetHeader(array $params);

// setParameters : Return Void
    $this->service->setParameters(array $params);
    
// setbody : Return Void
    $this->service->setBody(params)
    
// basicAuth : Return Void
    $this->service->basicAuth(username, password);

// getError : Return Json Obj
    $this->service->getError();