{"id":21825369,"url":"https://github.com/arslanramay/php-shopify-api","last_synced_at":"2025-04-14T05:20:47.883Z","repository":{"id":242854699,"uuid":"810303826","full_name":"arslanramay/php-shopify-api","owner":"arslanramay","description":"A simple Shopify PHP (Guzzle) API Wrapper to interact with Shopify Admin REST API and GraphQL API.","archived":false,"fork":false,"pushed_at":"2024-06-05T13:22:00.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T17:42:34.311Z","etag":null,"topics":["php8","shopify","shopify-api","shopify-app-development"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/arslanramay/php-shopify-api","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/arslanramay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2024-06-04T12:39:38.000Z","updated_at":"2024-07-08T07:19:19.000Z","dependencies_parsed_at":"2024-06-05T11:18:24.427Z","dependency_job_id":"83a8296a-3a83-43cd-add9-062c1527c216","html_url":"https://github.com/arslanramay/php-shopify-api","commit_stats":null,"previous_names":["arslanramay/php-shopify-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arslanramay%2Fphp-shopify-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arslanramay%2Fphp-shopify-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arslanramay%2Fphp-shopify-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arslanramay%2Fphp-shopify-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arslanramay","download_url":"https://codeload.github.com/arslanramay/php-shopify-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248824993,"owners_count":21167412,"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":["php8","shopify","shopify-api","shopify-app-development"],"created_at":"2024-11-27T18:01:40.982Z","updated_at":"2025-04-14T05:20:47.864Z","avatar_url":"https://github.com/arslanramay.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\n\nA simple PHP API wrapper for Shopify using Guzzle [Shopify API](https://help.shopify.com/api/getting-started).\n\n## Installation\n\nInstall via [Composer](https://getcomposer.org/) by running `composer require arslanramay/php-shopify-api` in your project directory.\n\n## Usage\n\nIn order to use this wrapper library you will need to provide credentials to access Shopify's API.\n\nYou will either need an access token for the shop you are trying to access (if using a [public application](https://help.shopify.com/api/getting-started/authentication#public-applications)) or an API Key and Secret for a [private application](https://help.shopify.com/api/getting-started/authentication#private-applications).\n\n## Code Examples\n\n#### Make an API call\n```php\nuse arslanramay\\ShopifyPHP\\Shopify;\n\n// Initialize the client\n$shopify = new Shopify('exampleshop.myshopify.com', 'mysupersecrettoken');\n\n// Get all products\n$result = $shopify-\u003ecall('GET', 'admin/products.json');\n\n// Get the products with ids of '9326553104669' and '9339160002845' with only the 'id', 'images', and 'title' fields\n$result = $shopify-\u003ecall('GET', 'admin/products.json', [\n    'ids' =\u003e '9326553104669,9339160002845',\n    'fields' =\u003e 'id,images,title',\n]);\n\n// Create a new product with title \"Kerastase Shampoo 150ml\"\n$result = $shopify-\u003ecall('POST', 'admin/products.json', [\n    'product' =\u003e [\n        \"title\"        =\u003e \"Kerastase Shampoo 150ml\",\n        \"body_html\"    =\u003e \"\u003cstrong\u003eGood shampoo for hair!\u003c/strong\u003e\",\n        \"vendor\"       =\u003e \"Kerastase\",\n        \"product_type\" =\u003e \"Shampoo\",\n        \"tags\"         =\u003e 'Shampoo, Kerastase, \"Hair Care\"',\n    ],\n]);\n```\n\n#### Use Private Application API Credentials to authenticate API requests\n```php\nuse arslanramay\\ShopifyPHP\\Shopify;\n\n$shopify = new Shopify($data['shop'], [\n    'api_key' =\u003e '...',\n    'secret'  =\u003e '...',\n]);\n```\n\n#### Use an access token to authenticate API requests\n```php\nuse arslanramay\\ShopifyPHP\\Shopify;\n\n$storedToken = ''; // Retrieve the stored token for the shop in question\n$shopify = new Shopify('exampleshop.myshopify.com', $storedToken);\n```\n\n#### Request an access_token for a shop\n```php\nuse arslanramay\\ShopifyPHP\\Shopify;\n\nfunction make_authorization_attempt($shop, $scopes)\n{\n    $shopify = new Shopify($shop, [\n        'api_key' =\u003e '...',\n        'secret'  =\u003e '...',\n    ]);\n\n    $nonce = bin2hex(random_bytes(10));\n\n    // Store a record of the shop attempting to authenticate and the nonce provided\n    $storedAttempts = file_get_contents('authattempts.json');\n    $storedAttempts = $storedAttempts ? json_decode($storedAttempts) : [];\n    $storedAttempts[] = ['shop' =\u003e $shop, 'nonce' =\u003e $nonce, 'scopes' =\u003e $scopes];\n    file_put_contents('authattempts.json', json_encode($storedAttempts));\n\n    return $shopify-\u003egetAuthorizeUrl($scopes, 'https://example.com/handle/shopify/callback', $nonce);\n}\n\nheader('Location: ' . make_authorization_attempt('exampleshop.myshopify.com', ['read_product']));\ndie();\n```\n\n#### Handle Shopify's response to the authorization request\n```php\nuse arslanramay\\ShopifyPHP\\Shopify;\n\nfunction check_authorization_attempt()\n{\n    $data = $_GET;\n\n    $shopify = new Shopify($data['shop'], [\n        'api_key' =\u003e '...',\n        'secret'  =\u003e '...',\n    ]);\n\n    $storedAttempt = null;\n    $attempts = json_decode(file_get_contents('authattempts.json'));\n    foreach ($attempts as $attempt) {\n        if ($attempt-\u003eshop === $data['shop']) {\n            $storedAttempt = $attempt;\n            break;\n        }\n    }\n\n    return $shopify-\u003eauthorizeApplication($storedAttempt-\u003enonce, $data);\n}\n\n$response = check_authorization_attempt();\nif ($response) {\n    // Store the access token for later use\n    $response-\u003eaccess_token;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farslanramay%2Fphp-shopify-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farslanramay%2Fphp-shopify-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farslanramay%2Fphp-shopify-api/lists"}