We have a new and more feature complete PHP example available on your new API quick guide here.
In this example, you will need the url of the site you're using and a public api key which can be generated by an admin of that site.
Basic example #1:
<?php // -------------------- // Config // -------------------- define('REC_API_URL', 'your site url'); // e.g. https://www.site.com/ define('REC_API_KEY', 'public api key'); define('REC_API_DEFAULT_LIMIT', 100); // default limit, feel free to change define('REC_API_DEFAULT_FIELDS', '*'); // default to return all fields, set to blank for faster method but just returns basic fields // -------------------- // Functions // -------------------- /** * Helper to make simple API requests to REC * * @param string $resourceName e.g. products or categories * @param int|null $id optional specific resource id e.g. the product id * @param array $options optional values to pass to the API * * @return array * * @throws Exception if API request failed */ function requestFromREC($resourceName, $id=null, $options=[]) { // build url params $options = http_build_query(array_merge([ 'api_key' => REC_API_KEY, 'limit' => REC_API_DEFAULT_LIMIT, 'fields' => REC_API_DEFAULT_FIELDS, ], $options)); // make request $resource = $resourceName . (! is_null($id) ? '/' . $id : ''); $response = @file_get_contents(REC_API_URL . 'api/v1/' . $resource . '.json?' . $options); if ($response === FALSE) { throw new Exception('Failed to reach API, please check your REC_API_URL & REC_API_KEY are set correctly'); } // decode response return json_decode($response); } // -------------------- // Example uses // -------------------- // list 100 products $products = requestFromREC('products'); var_dump($products); // or request details on just product id=32 $product = requestFromREC('products', 32); var_dump($product);
For more details, please read our full docs on: http://support.reallyeasycart.co.uk/support/solutions/folders/269622