{"id":20026252,"url":"https://github.com/adamculp/api-consumer","last_synced_at":"2025-05-05T02:31:15.125Z","repository":{"id":4927640,"uuid":"6084238","full_name":"adamculp/api-consumer","owner":"adamculp","description":"Wrapper class to consume APIs through GET using Curl. Based on PHP 7.3. (created to consume some APIs)","archived":false,"fork":false,"pushed_at":"2019-02-24T00:34:54.000Z","size":38,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-26T18:18:05.242Z","etag":null,"topics":["api-consumer","curl","php","rest-client"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"nakiostudio/ZXingObjC","license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamculp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-05T01:05:41.000Z","updated_at":"2024-04-25T09:55:43.000Z","dependencies_parsed_at":"2022-08-21T06:20:48.656Z","dependency_job_id":null,"html_url":"https://github.com/adamculp/api-consumer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamculp%2Fapi-consumer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamculp%2Fapi-consumer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamculp%2Fapi-consumer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamculp%2Fapi-consumer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamculp","download_url":"https://codeload.github.com/adamculp/api-consumer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252427816,"owners_count":21746279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-consumer","curl","php","rest-client"],"created_at":"2024-11-13T09:05:59.384Z","updated_at":"2025-05-05T02:31:14.742Z","avatar_url":"https://github.com/adamculp.png","language":"PHP","readme":"[![CircleCI](https://circleci.com/gh/adamculp/api-consumer.svg?style=svg)](https://circleci.com/gh/adamculp/api-consumer)\n\nAbout\n-----\n\nSimple PHP 7.3 class to consume an API through GET using Curl. (created to consume APIs, and could be used for other\nthings) Methods build API URL params, connection url, and parse expected JSON response.\n\nIn the future I intend to add the possibility of an XML return as well, and may even break out the limited Curl\nfunctionality to another class, or simply use Guzzle.\n\nRequirements\n------------\n\nRequires PHP version 7.3 if namespaces are desired.\n\nInstallation\n------------\n\nThis class can be used directly from a GIT clone:\n\n    git clone https://github.com/adamculp/api-consumer.git\n\nYou could also download the ApiConsumer package and move the directory to a desired location where your scripts can then\ncall it.\n\nAlternatively you could simply copy the ApiConsumer.php file to a desired location and call it that way as well.\n\nNon-Composer Usage\n------------------\n\nThis class was written using namespaces available via PHP 5.3+, and if left unchanged would be used in the following manner:\nNOTE: This class contains information needed to utilize a certain Mashery API at Active.com, but you can change the URL\nand params as needed for other APIs that return JSON.\n\n    require_once 'path/to/src/ApiConsumer/Consumer.php';\n    use ApiConsumer\\Consumer;\n    \n    $apiConsumer = new Consumer();\n    $url = 'http://api.amp.active.com/search?';\n    \n    $apiConsumer-\u003esetUrl($url);\n    \n    $meta = 'meta:channel=Running+meta:startDate:daterange:today..' . date('Y-m-d', strtotime('next month'));\n    $params = array(\n                    'k' =\u003e 'ultra+marathon',\n                    'v' =\u003e 'json',\n                    'l' =\u003e 'Florida',\n                    'r' =\u003e '25',\n                    's' =\u003e 'date_asc',\n                    'api_key' =\u003e '{Add API Key Here}',\n                    'm' =\u003e $meta\n                );\n                \n    $options = array(); // key=\u003evalue pairs can be added here to alter the curl call\n    \n    $apiConsumer-\u003esetParams($params);\n    \n    $apiConsumer-\u003esetOptions($options);\n    \n    $apiConsumer-\u003esetResponseType('json');\n    $apiConsumer-\u003esetCallType('get');\n    \n    $result = $apiConsumer-\u003edoApiCall();\n\nComposer Usage\n------------------\n\nAfter either installing Composer using one of the two methods shown at http://getcomposer.org the composer.json would\nlook like:\n\n    {\n        \"require\": {\n            \"adamculp/api-consumer\": \"dev-master\"\n        }\n    }\n\nThen you'll need to alter the require_once in the sample above to point to the Composer autoload instead of to the class\nitself.\n\n    require_once 'vendor/autoload.php'; // to include the composer autoloader\n\n\nFrom there you can use the $result array as you see fit.\n\nPlease use the /api-consumer/index.php as a working example (minus the API key) of how the class can be included and used.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamculp%2Fapi-consumer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamculp%2Fapi-consumer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamculp%2Fapi-consumer/lists"}