arturmamedov / w-api
Simple PHP Class for call an REST API endpoint and get JSON data with CURL
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/arturmamedov/w-api
This package is auto-updated.
Last update: 2025-09-19 22:01:39 UTC
README
REST PHP API Consumer
Simple PHP Class for call an REST API endpoint and get JSON data with CURL
Example
<?php $endpoint = 'blog/posts'; // relative to what set in $host and $version in MyApi Class // so result: http://api.test/api/v1/blog/posts # 1 - Include and init require_once 'src'.DIRECTORY_SEPARATOR.'api.php'; $w_api = new wApi('testuser', 'testpassword'); # 2 - Make call $json_response = $w_api->http($endpoint, 'GET'); # 3 - Read Response if ($response === false) { $response = [ 'status' => false, 'error' => 'CURL_ERR' ]; exit(print_r($response)); // for debug reason, to remove in production }else { $response = json_decode($json_response); } // Use $response ... foreach ($response as $post){ // do things with your resource }
Author: Artur Mamedov
Inspired by: https://github.com/abraham/twitteroauth