PHP code example of palanik / wrapi

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

    

palanik / wrapi example snippets


"function_name" => array(
	"method" => "HTTP_METHOD",					// 'GET', 'POST', 'PUT', 'PATCH' or 'DELETE'
	"path" => "relative/path/to/:api/endpoint"	// Can use `Slim`/`express` style path params
)

array(
	"repo" => array(
		"method" => "GET",
		"path" => "repos/:owner/:repo"
	),

	"contributors" => array(
		"method" => "GET",
		"path" => "repos/:owner/:repo/contributors"
	),

	"languages" => array(
		"method" => "GET",
		"path" => "repos/:owner/:repo/languages"
	),

	"tags" => array(
		"method" => "GET",
		"path" => "repos/:owner/:repo/tags"
	),

	"branches" => array(
		"method" => "GET",
		"path" => "repos/:owner/:repo/branches"
	)
)

$endpoints = array(...);

$client = new wrapi\wrapi('https://api.github.com/',	// base url for the API
  endpoints 										// your endpoints array
);

// client object contains functions to call the API

$client("zen", 
	array(
		"method" => "GET",
		"path" => "zen"
		)
	);

// This will make GET request to 'https://api.github.com/repos/guzzle/guzzle/contributors'
$contributors = $client->contributors('guzzle', 'guzzle');

$zenQuote = $client->zen();
echo "Today's quote: ". $zenQuote;



$client(function_name, endpoint_definition)