{"id":16489477,"url":"https://github.com/j0k3r/php-imgur-api-client","last_synced_at":"2025-07-15T17:37:24.051Z","repository":{"id":14242670,"uuid":"16950010","full_name":"j0k3r/php-imgur-api-client","owner":"j0k3r","description":"A PHP Imgur API Client using Guzzle 3, 5 or 6","archived":false,"fork":false,"pushed_at":"2024-03-05T08:14:15.000Z","size":3053,"stargazers_count":79,"open_issues_count":3,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-20T04:38:51.773Z","etag":null,"topics":["client","guzzle","imgur","imgur-api","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/j0k3r.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"j0k3r"}},"created_at":"2014-02-18T13:40:44.000Z","updated_at":"2025-06-19T09:40:03.000Z","dependencies_parsed_at":"2024-03-05T09:28:35.502Z","dependency_job_id":"e81166ac-4d34-41c0-9645-c37a61fbed52","html_url":"https://github.com/j0k3r/php-imgur-api-client","commit_stats":{"total_commits":150,"total_committers":8,"mean_commits":18.75,"dds":0.5333333333333333,"last_synced_commit":"054703921dfceb4680481d52f96292da8919a278"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/j0k3r/php-imgur-api-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j0k3r%2Fphp-imgur-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j0k3r%2Fphp-imgur-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j0k3r%2Fphp-imgur-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j0k3r%2Fphp-imgur-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/j0k3r","download_url":"https://codeload.github.com/j0k3r/php-imgur-api-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j0k3r%2Fphp-imgur-api-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265450594,"owners_count":23767651,"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":["client","guzzle","imgur","imgur-api","php"],"created_at":"2024-10-11T13:44:15.602Z","updated_at":"2025-07-15T17:37:24.008Z","avatar_url":"https://github.com/j0k3r.png","language":"PHP","readme":"# PHP Imgur API Client\n\n![CI](https://github.com/j0k3r/php-imgur-api-client/workflows/CI/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/j0k3r/php-imgur-api-client/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/j0k3r/php-imgur-api-client?branch=master)\n[![Total Downloads](https://poser.pugx.org/j0k3r/php-imgur-api-client/downloads)](https://packagist.org/packages/j0k3r/php-imgur-api-client)\n[![License](https://poser.pugx.org/j0k3r/php-imgur-api-client/license)](https://packagist.org/packages/j0k3r/php-imgur-api-client)\n\nObject Oriented PHP wrapper for the Imgur API.\n\nUses [Imgur API v3](https://api.imgur.com/).\n\n## Information\n\n* Branch [1.x](https://github.com/j0k3r/php-imgur-api-client/tree/1.x) use Guzzle 3 (but is not maintained)\n* Branch [2.x](https://github.com/j0k3r/php-imgur-api-client/tree/2.x) use Guzzle 5 (but is not maintained)\n* Branch [3.x](https://github.com/j0k3r/php-imgur-api-client/tree/3.x) use Guzzle 6 and PHP \u003e= 5.6\n* Branch [master](https://github.com/j0k3r/php-imgur-api-client/tree/master) use Guzzle 7 and PHP \u003e= 7.4\n\n## Composer\n\nDownload Composer\n\n```bash\n$ curl -s http://getcomposer.org/installer | php\n```\n\nAdd the library details to your composer.json\n\n```bash\ncomposer require j0k3r/php-imgur-api-client@^4.0\n```\n\nInstall the dependency with\n\n```bash\n$ php composer.phar install\n```\n\n## Basic usage\n\n```php\n// This file is generated by Composer\nrequire_once 'vendor/autoload.php';\n\n$client = new \\Imgur\\Client();\n$client-\u003esetOption('client_id', '[your app client id]');\n$client-\u003esetOption('client_secret', '[your app client secret]');\n\nif (isset($_SESSION['token'])) {\n    $client-\u003esetAccessToken($_SESSION['token']);\n\n    if ($client-\u003echeckAccessTokenExpired()) {\n        $client-\u003erefreshToken();\n    }\n} elseif (isset($_GET['code'])) {\n    $client-\u003erequestAccessToken($_GET['code']);\n    $_SESSION['token'] = $client-\u003egetAccessToken();\n} else {\n    echo '\u003ca href=\"'.$client-\u003egetAuthenticationUrl().'\"\u003eClick to authorize\u003c/a\u003e';\n}\n```\n\nThe API calls can be accessed via the `$client` object\n\n```php\n$memes = $client-\u003eapi('memegen')-\u003edefaultMemes();\n```\n\n## Documentation\n\n### Basic information\n\nThis client follow the same tree as the [Imgur API](https://apidocs.imgur.com).\n\nHere is the list of available _endpoints_: `account`, `album`, `comment`, `custom gallery`, `gallery`, `image`, `conversation`, `notification`, `memegen` \u0026 `topic`.\n\nYou can access each endpoint using the `api()` method:\n\n```php\n$client-\u003eapi('album');\n$client-\u003eapi('comment');\n$client-\u003eapi('customGallery');\n// etc ...\n```\n\nAll available methods for each endpoints are in the folder [Api](lib/Imgur/Api). They mostly follow the description name in the Imgur doc. Here are few examples:\n\n```php\n// for \"Account Base\" in account\n$client-\u003eapi('account')-\u003ebase();\n// for \"Account Gallery Profile\" in account\n$client-\u003eapi('account')-\u003eaccountGalleryProfile();\n\n// for \"Filtered Out Gallery\" in Custom Gallery\n$client-\u003eapi('customGallery')-\u003efiltered();\n\n// for \"Random Gallery Images\" in gallery\n$client-\u003eapi('gallery')-\u003erandomGalleryImages();\n\n// etc ...\n```\n\n### Uploading an image\n\nIf you want to **upload an image** you can use one of these solutions:\n\n```php\n$pathToFile = '../path/to/file.jpg';\n$imageData = [\n    'image' =\u003e $pathToFile,\n    'type'  =\u003e 'file',\n];\n\n$client-\u003eapi('image')-\u003eupload($imageData);\n```\n\nor\n\n\n```php\n$urlToFile = 'http://0.0.0.0/path/to/file.jpg';\n$imageData = [\n    'image' =\u003e $urlToFile,\n    'type'  =\u003e 'url',\n];\n\n$client-\u003eapi('image')-\u003eupload($imageData);\n```\n\nor\n\n\n```php\n$pathToFile = '../path/to/file.jpg';\n$imageData = [\n    'image' =\u003e base64_encode(file_get_contents($pathToFile)),\n    'type'  =\u003e 'base64',\n];\n\n$client-\u003eapi('image')-\u003eupload($imageData);\n```\n\n### Pagination\n\nFor any API call that supports pagination and is not explicitly available via the method parameters, it can be achieved by using the `BasicPager` object and passing it as the second parameter in the `api()` call.\n\n```php\n$pager = new \\Imgur\\Pager\\BasicPager(1, 10);\n$images = $client-\u003eapi('account', $pager)-\u003eimages();\n```\n\nHere is a real life example if you want to retrieve all your available images of an account:\n\n```php\n$page = 1;\n$pager = new \\Imgur\\Pager\\BasicPager();\n$res = $client-\u003eapi('account', $pager)-\u003eimages();\n\nwhile (!empty($res)) {\n    // var_dump(count($res));\n\n    $pager-\u003esetPage($page++);\n\n    $res = $client-\u003eapi('account', $pager)-\u003eimages();\n}\n```\n\nThis pager is really basic:\n\n - You won't have information about how many pages are available\n - If you request a non-existant page, you'll get an empty array\n\nNOTE: `/gallery` endpoints do not support the `perPage` query string, and `/album/{id}/images` is not paged.\n\nPlease, read the [Imgur doc about it](https://api.imgur.com/#paging_results).\n\n### Image id or Album id ?\n\nWhen you got an Imgur link it's almost impossible to be 100% sure if it's an image or an album.\nThat's why we have an endpoint which might fix that by first checking an id as an image and if it's fail, test it as an album:\n\n\n```php\n$data = $client-\u003eapi('albumOrImage')-\u003efind($id);\n```\n\n## License\n\n`php-imgur-api-client` is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","funding_links":["https://github.com/sponsors/j0k3r"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj0k3r%2Fphp-imgur-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj0k3r%2Fphp-imgur-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj0k3r%2Fphp-imgur-api-client/lists"}