Quick PHP Integration Guide

A 5 minute guide for quick integration, suitable for PHP based websites and custom e-shops


Note: This page is now deprecated. See the new Integration Guide for the most up-to-date information.

General overview

This guide relies on the Youstice PHP library. The library is compatible with PHP 5.3+ and allows any developer to integrate Youstice platform easily, comfortably and blazingly fast. There are only a handful of API calls you have to make in order to start using the Youstice platform on your site. The library provides a fluent interface with easy to understand and easily readable API calls.

If you're site is actually based on Prestashop, Magento, OpenCart, WooCommerce or Shopify, you're better of by getting one of the specific plug-ins for those e-Shop platforms.

This guide will walk you through the integration steps with the following goals:

  • Show the 'Youstice Widget' on your website
  • Ability to file claims directly from your website

See the full PHP integration guide if you want to have the best possible integration and use all the available features.

Note: Implementing this guide will allow your visitors to file a claim regardless whether they actually purchased goods from your shop or not, and thus opens the door for possible SPAM. You're strongly encouraged to use Captcha, or consider the full-featured integration with purchase validation.

Download the PHP library here. Last updated: Feb. 27, 2015

Logos of various color scheme and size are available here

Our recommendation: Place this logo on a visible location on your website as a link to the Youstice Badge (clicking on the logo would display the badge).


  • Target environment for the integration: SANDBOX, or PRODUCTION
  • Successful registration into Youstice (either SANDBOX, or PRODUCTION) as a retailer with at least 1 shop
  • The API Key for your shop
  • Basic familiarity with the PHP programming language

This guide assumes integration into the SANDBOX environment, which is a good place to get started.

Integrating the PHP library into your site

1. Initialization

Constructs the Youstice API object and set all the required parameters, most notably the API key. The library will throw exceptions on any errors, e.g. if the provided API key is invalid.

Note: This code should be executed before any content was sent to a browser due to session initialization

<?PHP require('./Youstice/SimpleApi.php'); // set this to 'false' if you want to use the PRODUCTION environment $is_sandbox = true; // remember to provide an API key that corresponds with the environment specified above $api_key = "YOUR_SHOPS_API_KEY_GOES_HERE"; $yapi = Youstice_Simple_Api::create() ->setLanguage('en') ->setThisShopSells('product') // use either 'product' or 'service' ->setApiKey($api_key, $is_sandbox); $yapi->run(); $section = $_GET['section']; if ($section=='fileClaim') { try { $redirect_url = $yapi->createWebReport(); } catch (Youstice_InvalidApiKeyException $e) { exit('Invalid API key'); }catch (Youstice_FailedRemoteConnectionException $e) { exit('Connection to remote server failed, please try again later'); } header('Location: '.$redirect_url); exit; } ?>

Once this is done, you can use the API calls below, to:

  • Display the Youstice Widget on your site
  • Allow your visitors to submit claims for your shop

2. Display the Youstice Widget

The following code snippet will display the Youstice Widget (logo + generic info):

try{ echo $yapi->getLogoWidgetHtml(); }catch (Youstice_InvalidApiKeyException $e) { exit('Invalid API key'); }catch (Youstice_FailedRemoteConnectionException $e) { exit('Connection to remote server failed, please try again later'); }

You may want to place this piece of code somewhere in your site's footer section. However, the exact placement is entirely up to you. You may choose not to use this call at all. If done properly, it should display the following image on your site:

Youstice - logo widget

3. File a claim

Filing a claim involves two steps. First, you create a HTML UI element (a button), and second, you contact Youstice when the button is clicked.

3.1 Create a Button

A 'web report' button will allow your visitors to file a claim via Youstice. To display the button, simply call the API method below. The URL address your code to handle the button-click action is passed as a parameter:

try { echo $yapi->getWebReportButtonHtml('index.php?section=fileClaim'); // do not forget to change "index.php" to name of the name of a page where this code is included (current page) }catch (Youstice_InvalidApiKeyException $e) { exit('Invalid API key'); }catch (Youstice_FailedRemoteConnectionException $e) { exit('Connection to remote server failed, please try again later'); }

Note: Method getWebReportButtonHtml() includes a CSS style tag, so this button is styled automatically and including a separate Youstice stylesheet is not necessary.