1. Go to this page and download the library: Download jakiboy/apaapi 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/ */
jakiboy / apaapi example snippets
/**
* @see You can use Composer,
* Or e Apaapi\lib\Request;
use Apaapi\lib\Response;
/**
* @see With Three Easy Steps,
* You can Achieve Quick Connection to Amazon Affiliate Program,
* Via Amazon Product Advertising API Library.
*/
// (1) Set Operation
$operation = new SearchItems();
$operation->setPartnerTag('{Your-partner-tag}')->setKeywords('{Your-keywords}');
// (2) Prapere Request
$request = new Request('{Your-key-id}','{Your-secrect-key}');
$request->setLocale('{Your-region}')->setPayload($operation);
// (3) Get Response
$response = new Response($request);
echo $response->get(); // JSON ready for parsing
use Apaapi\operations\GetItems;
use Apaapi\operations\SearchItems;
use Apaapi\operations\GetVariations;
use Apaapi\operations\GetBrowseNodes;
/**
* @see 4 Operations.
* @see https://webservices.amazon.com/paapi5/documentation/operations.html
*/
// GetItems
$operation = new GetItems();
$operation->setPartnerTag('{Your-partner-tag}')
->setItemIds(['{ASIN}']); // Array|String
// SearchItems
$operation = new SearchItems();
$operation->setPartnerTag('{Your-partner-tag}')
->setKeywords('{Your-keywords}'); // Array|String
// GetVariations
$operation = new GetVariations();
$operation->setPartnerTag('{Your-partner-tag}')
->setASIN('{ASIN}'); // String
// GetBrowseNodes
$operation = new GetBrowseNodes();
$operation->setPartnerTag('{Your-partner-tag}')
->setBrowseNodeIds(['{NodeId}']); // Array|String
/**
* @see Using setResources() method to set custom ressources,
* Instead of default ressources,
* This can improve response time.
*/
// Set Operation
$operation->setPartnerTag('{Your-partner-tag}')->setKeywords('{Your-keywords}')
->setResources(['Images.Primary.Small','ItemInfo.Title','Offers.Listings.Price']);
use Apaapi\operations\GetItems;
use Apaapi\lib\Request;
use Apaapi\lib\Response;
use Apaapi\her Stream Instead.
*/
class MyRequestClient extends RequestClient
{
// ...
}
// Set Operation
$operation = new GetItems();
$operation->setPartnerTag('{Your-partner-tag}')->setItemIds('{ASIN}');
// Prapere Request
$request = new Request('{Your-key-id}','{Your-secrect-key}');
$request->setLocale('{your-region}')->setPayload($operation);
// Set Custom Client After Payload
$request->setClient(
new MyRequestClient($request->getEndpoint(), $request->getParams())
);
// Get Response
$response = new Response($request);
echo $response->get(); // JSON ready for parsing
use Apaapi\e Helps generating quick decoded response.
* @param object|array|serialized
*/
// Get Response
$response = new Response($request, new ResponseType('array'));
return $response->get(); // Array ready to be used
use Apaapi\e Helps parsing response.
* @param Response::PARSE
*/
// Get Response
$response = new Response($request, new ResponseType('object'), Response::PARSE);
return $response->get(); // Object ready to be used