{"id":22974157,"url":"https://github.com/diversen/simple-php-github-api","last_synced_at":"2025-08-20T06:42:27.709Z","repository":{"id":6102988,"uuid":"7330413","full_name":"diversen/simple-php-github-api","owner":"diversen","description":"a simple php github api","archived":false,"fork":false,"pushed_at":"2016-02-16T10:24:54.000Z","size":479,"stargazers_count":15,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-13T14:46:02.294Z","etag":null,"topics":["github-api"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diversen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-26T18:26:22.000Z","updated_at":"2023-12-05T15:06:23.000Z","dependencies_parsed_at":"2022-09-13T02:42:02.384Z","dependency_job_id":null,"html_url":"https://github.com/diversen/simple-php-github-api","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/diversen/simple-php-github-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diversen%2Fsimple-php-github-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diversen%2Fsimple-php-github-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diversen%2Fsimple-php-github-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diversen%2Fsimple-php-github-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diversen","download_url":"https://codeload.github.com/diversen/simple-php-github-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diversen%2Fsimple-php-github-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271279538,"owners_count":24731902,"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","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["github-api"],"created_at":"2024-12-15T00:00:24.610Z","updated_at":"2025-08-20T06:42:27.666Z","avatar_url":"https://github.com/diversen.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\n\nVery simple github API for PHP using OAuth. 37 LOC for the API class. And a\ncurl helper class with 84 LOC.\n\n# Install `simple-php-github-api`\n\n    php composer.phar require diversen/simple-php-github-api:\n    \nOr if you have placed composer.phar in `your path` as composer\n\n    composer require diversen/simple-php-github-api\n\n# Brief explantion.\n\nThere is really only tree methods you can do. Let us see those three methods first. \n(Further below is an complete example using the built-in server for easy testing). \n\n1) Generate an access URL to github.com\n\n~~~.php\n$access_config = array (\n    'redirect_uri' =\u003e GITHUB_CALLBACK_URL,\n    'client_id' =\u003e GITHUB_ID,\n    'state' =\u003e  md5(uniqid()),\n    'scope' =\u003e 'user' \n);\n\n$api = new githubapi();\n$url = $api-\u003egetAccessUrl($access_config);\necho \"\u003ca href=\\\"$url\\\"\u003eGithub Login\u003c/a\u003e\";\n~~~\n\n2) Callback from github.com\n\n~~~.php\n$access_config = array (\n    'redirect_uri' =\u003e GITHUB_CALLBACK_URL,\n    'client_id' =\u003e GITHUB_ID,\n    'client_secret' =\u003e GITHUB_SECRET\n);\n\n$api = new githubapi();\n$res = $api-\u003esetAccessToken($access_config);\n\nif ($res) {\n    // OK\n    This is where we will call the api\n    header(\"Location: /api_call.php\");\n} else {\n    // Not OK. echo errors\n    echo \"Could not get access token. Errors: \u003cbr /\u003e\";\n    print_r($api-\u003eerrors);\n}\n~~~\n\n3) API call\n\nFor full listing see: [https://developer.github.com/v3/](https://developer.github.com/v3/)\n\n~~~.php\n// We have a access token and we can now call the api: \n$api = new githubapi();\n\n// Simple call - API get current users credentials\n// This can also be done without scope\n\n// example\n// $command = '/user', \n// $request = 'GET', 'POST' or 'PATCH' or 'DELETE' etc. Se API: \n// $post = variables to POST array\n\n$command = \"/user\";\n$res = $api-\u003eapiCall($command, $request = null, $post = null);\nif (!$res) {\n    print_r($api-\u003eerrors); \n    die;\n} else {\n    print_r($res);\n}\n~~~\n\n# Full example\n\nExample you can run right away using the built-in PHP-server. \n\n## Make a github app\n\nLog into [github.com](github.com)\n\nRegister a new application at [https://github.com/settings/developers](https://github.com/settings/developers)\n\nYou will see something like this: \n\n![My settings](https://raw.githubusercontent.com/diversen/simple-php-github-api/master/github-api.png \"My settings\")\n\nCreate your app. \n\nEnter base_dir of the `simple-php-github-api`:\n\n    cd vendor/diversen/simple-php-github-api\n\n## Configuration\n\n    cp example/config.php-dist example/config.php\n\nEdit config\n\nSet config in `example/config.php` according to above settings and \nthe screenshot above.\n\nRun test-server with example:\n\n    php -S localhost:8080 -t example/\n\n## More github API info\n\nFor full listing of all API calls check: \n\n[https://developer.github.com/v3/](https://developer.github.com/v3/)\n\nScope: \n\n[https://developer.github.com/v3/oauth/#scopes](https://developer.github.com/v3/oauth/#scopes)\n\nI have not tested many calls - but you should be able to use all. E.g. POST,\nor PATCH, DELETE.\n\n## Support\n\nCreate an issue, and Let me hear if it does not work out for you.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiversen%2Fsimple-php-github-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiversen%2Fsimple-php-github-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiversen%2Fsimple-php-github-api/lists"}