2017 © Pedro Peláez
 

library vend-php

Simple Vend API client in PHP

image

offshoot/vend-php

Simple Vend API client in PHP

  • Wednesday, July 15, 2015
  • by chriswoodford
  • Repository
  • 6 Watchers
  • 5 Stars
  • 774 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 22 Forks
  • 0 Open issues
  • 5 Versions
  • 9 % Grown

The README.md

vend-php

A simple Vend API client in PHP., (*1)

The canoncial repository for this stream of development is https://github.com/TeamOffshoot/vend-php, (*2)

Requirements

  • PHP 5.3 (or higher)
  • ext-curl, ext-json
  • offshoot/http

Development Requirements

  • phpunit/phpunit 3.7

Getting Started

Install vend-php via Composer, (*3)

Create a composer.json file if you don't already have one in your projects root directory and require vend-php:, (*4)

{
  "require": {
    "offshoot/vend-php": "~1.0"
  }
}

To learn more about Composer, including the complete installation process, visit http://getcomposer.org/, (*5)

Using cURL

If you're using a cURL based HttpClient like the CurlHttpClient, you will want to include the cacert.pem file that can be found at http://curl.haxx.se/docs/caextract.html, (*6)

You can add this as a dependency in your composer file. Your composer.json might look something like this:, (*7)

{
  "require": {
    "offshoot/vend-php": "~1.0",
    "haxx-se/curl": "1.0.0"
  },
  "repositories": [
    {
      "type": "package",
      "package": {
        "name": "haxx-se/curl",
        "version": "1.0.0",
        "dist": {
          "url": "http://curl.haxx.se/ca/cacert.pem",
          "type": "file"
        }
      }
    }
  ]
}

You will be able to find the cacert.pem file in vendor/haxx-se/curl/cacert.pem, (*8)

Usage

Authentication

Getting an Access Token

If you do not already have a Vend API Permanent Access Token, you will need you authenticate with the Vend API first, (*9)

$pathToCertificateFile = 'vendor/haxx-se/curl/cacert.pem';
$httpClient = new \Offshoot\HttpClient\CurlHttpClient($pathToCertificateFile);
$redirector = new \Offshoot\Redirector\HeaderRedirector();

$authenticate = new \Vend\Api\AuthenticationGateway($httpClient, $redirector);

$authenticate->forStoreName('mycoolstore')
    ->usingClientId('XXX1234567890') // get this from your Vend Account
    ->andReturningTo('http://wherever.you/like')
    ->initiateLogin();

This will redirect your user to a Vend login screen where they will need to authenticate with their Vend credentials. After doing that, Vend will perform a GET request to your redirect URI, that will look like:, (*10)

GET http://wherever.you/like?code=TEMP_TOKEN&domain_prefix=YOUR_STORE_NAME

Your application will need to capture the code query param from the request and use that to get the access token from Vend, (*11)

// validate the Vend Request
if ($client->isValidRequest($_GET)) {

    // exchange the token
    $accessToken = $authenticate->forStoreName('mycoolstore')
        ->usingClientId('XXX1234567890') // get this from your Vend Account
        ->usingClientSecret('ABC123XYZ') // get this from your Vend Account
        ->andReturningTo('http://wherever.you/like')
        ->toExchange($_GET['code']);

}

Refreshing an Access Token

TBD, (*12)

Interacting with the Vend API

Set up the API Client

$vend = new \Vend\Api\Client($httpClient);
$vend->setStoreName('mycoolstore');
$vend->setAccessToken($accessToken);

Contributing

Contributions are welcome. Just fork the repository and send a pull request. Please be sure to include test coverage with your pull request. You can learn more about Pull Requests here, (*13)

In order to run the test suite, ensure that the development dependencies have been installed via composer. Then from your command line, simple run:, (*14)

vendor/bin/phpunit --bootstrap tests/bootstrap.php tests/

License

This library is released under the GPL 3.0 License, (*15)

Acknowledgements

Thanks to Bruce Aldridge for his development of the initial code base., (*16)

The Versions

15/07 2015

dev-master

9999999-dev https://github.com/TeamOffshoot/vend-php

Simple Vend API client in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bruce Aldridge
by Arjan Scherpenisse

shop e-commerce shopping vend

06/02 2015

0.9.x-dev

0.9.9999999.9999999-dev https://github.com/TeamOffshoot/vendAPI

Vend API class

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Bruce Aldridge
by Arjan Scherpenisse

shop e-commerce shopping

06/02 2015

0.9.0

0.9.0.0 https://github.com/TeamOffshoot/vendAPI

Vend API class

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Bruce Aldridge
by Arjan Scherpenisse

shop e-commerce shopping

06/02 2015

1.0.0

1.0.0.0 https://github.com/TeamOffshoot/vend-php

Simple Vend API client in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bruce Aldridge
by Arjan Scherpenisse

shop e-commerce shopping vend

01/02 2015

dev-oauth

dev-oauth https://github.com/TeamOffshoot/vend-php

Simple Vend API client in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bruce Aldridge
by Arjan Scherpenisse

shop e-commerce shopping vend