All Projects → slince → Shopify Api Php

slince / Shopify Api Php

Licence: mit
🚀 Shopify API Client for PHP

Projects that are alternatives of or similar to Shopify Api Php

Modio Unity
Unity Plugin for integrating mod.io - a modding API for game developers
Stars: ✭ 53 (-47%)
Mutual labels:  api, sdk
Openapi Generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Stars: ✭ 10,634 (+10534%)
Mutual labels:  api, sdk
Gopay Php Api
GoPay's PHP SDK for Payments REST API
Stars: ✭ 53 (-47%)
Mutual labels:  api, sdk
Nodejs
Everything related to the Node.js ecosystem for the commercetools platform.
Stars: ✭ 47 (-53%)
Mutual labels:  api, sdk
Modio Sdk Legacy
SDK for integrating mod.io into your game - a modding API for game developers
Stars: ✭ 75 (-25%)
Mutual labels:  api, sdk
Android Pdk
Pinterest Android SDK
Stars: ✭ 49 (-51%)
Mutual labels:  api, sdk
Nestia
Automatic SDK and Document generator for the NestJS
Stars: ✭ 57 (-43%)
Mutual labels:  api, sdk
Gocertcenter
CertCenter API Go Implementation
Stars: ✭ 21 (-79%)
Mutual labels:  api, sdk
Foal
Elegant and all-inclusive Node.Js web framework based on TypeScript. 🚀.
Stars: ✭ 1,176 (+1076%)
Mutual labels:  api, sdk
Directus Docker
Directus 6 Docker — Legacy Container [EOL]
Stars: ✭ 68 (-32%)
Mutual labels:  api, sdk
Waliyun
阿里云Node.js Open API SDK(完整版)
Stars: ✭ 40 (-60%)
Mutual labels:  api, sdk
Uploadcare Php
PHP API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
Stars: ✭ 77 (-23%)
Mutual labels:  api, sdk
Vainglory
(*DEPRECATED*: The API no longer exists, so this will no longer work) A Javascript API Client wrapper for Vainglory
Stars: ✭ 32 (-68%)
Mutual labels:  api, sdk
Js Api Client
Typeform API js client
Stars: ✭ 51 (-49%)
Mutual labels:  api, sdk
Aeris Ios Library
Contains a demo project utilizing the AerisWeather SDK for iOS to help you get started with using our library.
Stars: ✭ 21 (-79%)
Mutual labels:  api, sdk
Openrouteservice R
🌐 R package to query openrouteservice.org
Stars: ✭ 57 (-43%)
Mutual labels:  api, sdk
Pymessager
Python API to develop chatbot on Facebook Messenger Platform
Stars: ✭ 580 (+480%)
Mutual labels:  api, sdk
Themoviedb
A node.js module with support for both callbacks and promises to provide access to the TMDb API
Stars: ✭ 5 (-95%)
Mutual labels:  api, sdk
Domo Python Sdk
Python3 - Domo API SDK
Stars: ✭ 64 (-36%)
Mutual labels:  api, sdk
Huobi golang
Go SDK for Huobi Spot API
Stars: ✭ 76 (-24%)
Mutual labels:  api, sdk

🚀 PHP SDK for the Shopify API

Software License Build Status Coverage Status Latest Stable Version Scrutinizer Total Downloads

Installation

Install via composer

$ composer require slince/shopify-api-php

Quick Start

Initialize the client

You first need to initialize the client. For that you need your Shop Name and AccessToken

require __DIR__ . '/vendor/autoload.php';

$credential = new Slince\Shopify\PublicAppCredential('Access Token');
// Or Private App
$credential = new Slince\Shopify\PrivateAppCredential('API KEY', 'PASSWORD', 'SHARED SECRET');

$client = new Slince\Shopify\Client('your-store.myshopify.com', $credential, [
    'meta_cache_dir' => './tmp' // Metadata cache dir, required
]);

Middleware

Middleware augments the functionality of handlers by invoking them in the process of generating responses. Middleware is implemented as a higher order function that takes the following form.

$middleware = function(\Psr\Http\Message\ServerRequestInterface $request, callable $next){
    $response = $next($request);
    $this->logger->log($request, $response);
    return $response;
};

$client->getMiddlewares()->push($middleware);

Built-in middleware:

Exception

The Client throws the following types of exceptions.

Use Manager to manipulate your data;

  • Lists products
$products = $client->getProductManager()->findAll([
    // Filter your product
    'collection_id' => 841564295
    'page' => 2 // deprecated
]);
  • Lists products by pagination
$pagination = $client->getProductManager()->paginate([
    // filter your product
    'limit' => 3,
    'created_at_min' => '2015-04-25T16:15:47-04:00'
]);
// $pagination is instance of `Slince\Shopify\Common\CursorBasedPagination`

$currentProducts = $pagination->current(); //current page

while ($pagination->hasNext()) {
    $nextProducts = $pagination->next();
}

# to persist across requests you can use next_page_info and previous_page_info
$nextPageInfo = $pagination->getNextPageInfo();
$prevPageInfo = $pagination->getPrevPageInfo();

$products = $pagination->current($nextPageInfo);
  • Get the specified product
$product = $client->getProductManager()->find(12800);

// Update the given product
$product = $client->getProductManager()->update(12800, [
      "title" => "Burton Custom Freestyle 151",
      "body_html" => "<strong>Good snowboard!<\/strong>",
      "vendor"=> "Burton",
      "product_type" => "Snowboard",
]);
  • Creates a new product
$product = $client->getProductManager()->create([
      "title" => "Burton Custom Freestyle 151",
      "body_html" => "<strong>Good snowboard!<\/strong>",
      "vendor"=> "Burton",
      "product_type" => "Snowboard",
]);
  • Removes the product by its id
$client->getProductManager()->remove(12800);

The product is an instance of Slince\Shopify\Manager\Product\Product; You can access properties like following:

echo $product->getTitle();
echo $product->getCreatedAt(); // DateTime Object
//...
print_r($product->getVariants());
print_r($product->getImages());

Available managers:

You can access the manager like $client->getProductManager(), $client->getOrderManager().

Basic CURD

If you don't like to use managers, you can also manipulate data like this:

The returned value is just an array;

$products = $client->get('products', [
    // Filter your products
]);

$product = $client->get('products/12800');

$product = $client->post('products', [
    "product" => [
        "title" => "Burton Custom Freestyle 151",
        "body_html" => "<strong>Good snowboard!<\/strong>",
        "vendor"=> "Burton",
        "product_type" => "Snowboard",
        "images" => [
            [ 
                "attachment" => "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAw==\n"
            ]
        ]
     ]
]);

$product = $client->put('products/12800', [
    "product" => [
        "title" => "Burton Custom Freestyle 151",
        "body_html" => "<strong>Good snowboard!<\/strong>",
        "vendor"=> "Burton",
        "product_type" => "Snowboard",
        "images" => [
            [ 
                "attachment" => "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAw==\n"
            ]
        ]
     ]
]);

$client->delete('products/12800');

LICENSE

The MIT license. See MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].