PHP code example of kny00 / techspecs-php

1. Go to this page and download the library: Download kny00/techspecs-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kny00 / techspecs-php example snippets




// Importing the SDK class
use TechSpecsSDK\TechSpecsSDK;

// TechSpecs API Key
$techSpecsKey = 'techspecs_api_key';

// TechSpecs base https://apis.dashboard.techspecs.io/{techspecs_base}
$techSpecsBase = 'a8TD3mkN49fhg2y';

// Instantiate the Library
$techSpecs = new TechSpecsSDK($techSpecsBase, $techSpecsKey);

// product name or version number to search
$keyword = 'iPhone 13';

// product category to search
$category = ['all'];

// choose between "pretty" or "raw" mode for viewing response
$response = $techSpecs->search($keyword, $category, 'pretty');

// print the search results
print($response);




// Importing the SDK class
use TechSpecsSDK\TechSpecsSDK;

// TechSpecs API Key
$techSpecsKey = 'techspecs_api_key';

// TechSpecs base https://apis.dashboard.techspecs.io/{techspecs_base}
$techSpecsBase = 'a8TD3mkN49fhg2y';

// Instantiate the Library
$techSpecs = new TechSpecsSDK($techSpecsBase, $techSpecsKey);

// enter the page number to fetch results from
$page = 1;

/**
 * Type in the name of the brand you're looking for
 * or leave this field empty to see results from all brands
 */
$brand = ['Apple'];

/**
 * Type in the name of the category you're looking for
 * or leave this field empty to see results from all categories
 */
$category = ['smartphone'];

/**
 * Please provide a date range to narrow your search.
 * Leave this field empty to fetch all results from all dates
 */
$dateFrom = '2010-01-01'; // YYYY-MM-DD
$dateTo = '2022-03-15'; // YYYY-MM-DD

// Choose between "pretty" or "raw" mode for viewing response
$response = $techSpecs->products(
    $brand,
    $category,
    $dateFrom,
    $dateTo,
    $page,
    'pretty'
);

// Print the search results
print($response);




// Importing the SDK class
use TechSpecsSDK\TechSpecsSDK;

// TechSpecs API Key
$techSpecsKey = 'techspecs_api_key';

// TechSpecs base https://apis.dashboard.techspecs.io/{techspecs_base}
$techSpecsBase = 'a8TD3mkN49fhg2y';

// Instantiate the Library
$techSpecs = new TechSpecsSDK($techSpecsBase, $techSpecsKey);

// TechSpecs product id
$techspecsId = '6186b047987cda5f88311983';

// choose between "pretty" or "raw" mode for viewing response
$response = $techSpecs->productDetail($techspecsId, 'pretty');

// print the specifications of the product
print($response);




// Importing the SDK class
use TechSpecsSDK\TechSpecsSDK;

// TechSpecs API Key
$techSpecsKey = 'techspecs_api_key';

// TechSpecs base https://apis.dashboard.techspecs.io/{techspecs_base}
$techSpecsBase = 'a8TD3mkN49fhg2y';

// Instantiate the Library
$techSpecs = new TechSpecsSDK($techSpecsBase, $techSpecsKey);

// choose between "pretty" or "raw" mode for viewing response
$response = $techSpecs->brands('pretty');

// print the search results
print($response);




// Importing the SDK class
use TechSpecsSDK\TechSpecsSDK;

// TechSpecs API Key
$techSpecsKey = 'techspecs_api_key';

// TechSpecs base https://apis.dashboard.techspecs.io/{techspecs_base}
$techSpecsBase = 'a8TD3mkN49fhg2y';
// Instantiate the Library
$techSpecs = new TechSpecsSDK($techSpecsBase, $techSpecsKey);

// choose between "pretty" or "raw" mode for viewing response
$response = $techSpecs->categories('pretty');

// print the list of all categories
print($response);