SDK Php

Plan

I. Install a web server (for example wamp for windows)
I.1 Min requirements
II. Clone the Git repository in your root project folder
III. Run the 'composer update' command in the root path of the sdk folder to download Zend Framework dependencies
IV. Insert your API's credentials
IV.1 Requirements
IV. 2. Update the config files
V. Use the SDK
V.1. Use the endpoints
V.2. CDSApiClient Object
VI. Update the SDK
Notes

I. Install a web server (for example wamp for windows)

I.1. Min requirements
  • Apache 2.2. You can download the last version here
  • PHP 5.6. You can download the last version here

 

II. Clone the Git repository in your root project folder

The SDK is structured like that :


  • config/ : config files
  • samples/ : samples folder
  • sdk/ : content of the Cdiscount SDK (do not modify any file of this folder)

 

III. Run the 'composer update' command in the root path of the sdk folder to download Zend Framework dependencies

You can download the Composer-Setup.exe file or use command line to run the composer update like described here

 

IV. Insert your API's credentials

IV.1. Requirements

To use Cdiscount Marketplace API and Cdiscount Marketplace SDK you first need to follow the steps described in the Cdiscount Marketplace API website.

The sections are the following :

  • Request your account creation
  • Have set up your account
IV.2. Update the config files

Follow the procedure to insert your API credentials :

  • Open the config folder
  • Open the config.ini file
  • Set the API mode : 'preprod' or 'prod'
  • Open the preprod.config.ini file or the prod.config.ini file (if you set mode to 'prod')
  • Set your API Username
  • Set your API password

 

V. Use the SDK

V.1. Use the endpoints

An SDK is a Software Development Kit provided by Cdiscount Marketplace in order to make easier the interface with the API.

This SDK is developed with the PHP language and require at least a web server (for example Apache).

Then, you just have to download the SDK package, and to unpackage it on your server.

The SDK contains the following endpoints :

  • Seller
  • Offer
  • Discussion
  • Product
  • Order
  • Relays

All the SDK methods are described in the MarketPlace API Website because they have the same names of the Cdiscount Marketplace API methods.

For each method, you have a PHP file with a sample to call the corresponding API function.

For example, to call the GetSellerInformation API method, open the GetSellerInformation.php file contained in the Seller folder and follow the same steps of the sample.

V.2 CDSApiClient Object

The CDSApiClient allows you to call the API.

The CDSApiClient object contains all the endpoints. It's also create an API call to get a token for you.

Don't create a new CDSApiClient each time you call the API !

You can (have to) use the same CDSApiClient for all your API' calls.

Here an example of how use the same CDSApiClient for many API calls :
$client = new SdkApiClientCDSApiClient(); $token = $client->init(); if ($token == null || !$client->isTokenValid()) { echo "Souci lors de la génération du token"; die; } $offerPoint = $client->getOfferPoint(); $offerListResponse = $offerPoint->getOfferList(null); /** Parse here $offerListResponse **/ $sellerPoint = $client->getSellerPoint(); $sellerResponse = $sellerPoint->getSellerInformation(); /** Parse here $sellerResponse **/

 

VI. Update the SDK

Download the new SDK Zip file from the CDiscount Marketplace API Website.

Erase the SDK folder with the new one.

Erase the vendor folder with the new one.

To facilitate interactions with our systems and to offer an easier way to work with our API, we have recently put at your disposal our latest SDK PHP.

This SDK is now available on GitHub. This SDK will help you set up and update each in-coming improvement.
You are also welcome to join the GitHub community and to be part of the continuous improvement of our SDK.

 

Notes

In the sample, the parametrer error_reporting is set to '-1'. Do not let it in production mode.