<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AB-WebLog.com&#187; API</title>
	<atom:link href="http://www.ab-weblog.com/en/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ab-weblog.com/en</link>
	<description>Andreas Breitschopp</description>
	<lastBuildDate>Wed, 18 Mar 2015 09:47:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using the Shopping.com API in PHP</title>
		<link>http://www.ab-weblog.com/en/using-the-shopping-com-api-in-php/</link>
		<comments>http://www.ab-weblog.com/en/using-the-shopping-com-api-in-php/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 15:19:48 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Shopping.com]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=173</guid>
		<description><![CDATA[After an example of the eBay Finding API and the Amazon Product Advertising API in previous posts, I finally want to show an example of the Shopping.com API. First of all you need to register for a free Shopping.com developer &#8230; <a href="http://www.ab-weblog.com/en/using-the-shopping-com-api-in-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After an example of the <a title="Using the eBay Finding API in PHP" href="http://www.ab-weblog.com/en/using-the-ebay-finding-api-in-php/">eBay Finding API</a> and the <a title="Using the Amazon Product Advertising API in PHP" href="http://www.ab-weblog.com/en/using-the-amazon-product-advertising-api-in-php/">Amazon Product Advertising API</a> in previous posts, I finally want to show an example of the Shopping.com API.</p>
<p>First of all you need to register for a free <a title="Shopping.com Developer Website" href="http://developer.shopping.com" target="_blank">Shopping.com developer account</a>.</p>
<p>Then you can start building the API request URL:</p>
<pre class="brush: text; gutter: true">http://publisher.api.shopping.com/publisher/3.0/rest/GeneralSearch?
	apiKey=%apikey%&amp;
	trackingId=%trackingid%&amp;
	subTrackingId=%subTrackingId%&amp;
	categoryId=%categoryId%&amp;
	keyword=%keyword%&amp;
	pageNumber=%pageNumber%&amp;
	numItems=%numItems%&amp;
	hybridSortType=%hybridSortType%
	hybridSortOrder=%hybridSortOrder%</pre>
<p>Now let&#8217;s see what the individual parameters mean:</p>
<ul>
<li><em>GeneralSearch:</em> we need the operation <em><a title="More Info About the Operation GeneralSearch" href="http://developer.shopping.com/docs/read/API_Use_Cases#Searching" target="_blank">GeneralSearch</a></em> for our keyword-based search.</li>
<li><em>apiKey:</em> you get this API key in your Shopping.com developer account.</li>
<li><em>trackingId:</em> you need to request a tracking ID from Shopping.com to earn some money with your traffic.</li>
<li><em>subTrackingId:</em> choose any additional code here you want to use as optional tracking (e. g. for special campaigns).</li>
<li><em>categoryId:</em> the category you want to search in (leave empty to search in all categories).</li>
<li><em>keyword:</em> your search keywords. Make sure you use <em>utf8_decode</em> if the keywords are in UTF-8.</li>
<li><em>pageNumber:</em> for the first request you set this to <em>1</em> and increase it in previous requests if you need more items.</li>
<li><em>numItems:</em> here you can choose how many items (maximal 100) are returned per request.</li>
<li><em>hybridSortType:</em> choose if you want the result to be sorted by <em>relevance</em> or <em>price</em>.</li>
<li><em>hybridSortOrder:</em> choose if you want the result to be sorted <em>ascending</em> or <em>descending</em>.</li>
</ul>
<p>That&#8217;s all: we just need to pass this URL again to the small function we used already in the <a title="Using the eBay Finding API in PHP" href="http://www.ab-weblog.com/en/using-the-ebay-finding-api-in-php/">eBay Finding API</a> and the <a title="Using the Amazon Product Advertising API in PHP" href="http://www.ab-weblog.com/en/using-the-amazon-product-advertising-api-in-php/">Amazon Product Advertising API</a> examples and receive the XML response data:</p>
<pre class="brush: php; gutter: true">/**
 * Returns the SimpleXML object.
 *
 * @param string $url The URL to receive the XML document.
 * @return string The SimpleXML object.
 *
 */
function getXml($url) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_TIMEOUT, 3);
	$result = curl_exec($ch);
	curl_close($ch);

	return simplexml_load_string($result);
}</pre>
<p>As you can see the Shopping.com API is very easy to handle as it is also the smallest of these three APIs.</p>
<p><em>Did you use the Shopping.com API yourself already?<br />
Do you know other interesting online shopping APIs?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/using-the-shopping-com-api-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the Amazon Product Advertising API in PHP</title>
		<link>http://www.ab-weblog.com/en/using-the-amazon-product-advertising-api-in-php/</link>
		<comments>http://www.ab-weblog.com/en/using-the-amazon-product-advertising-api-in-php/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 14:04:46 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=172</guid>
		<description><![CDATA[As I have started with an example of the eBay Finding API in a previous post, I want to continue with the Amazon Product Advertising API now. Again we need to start with a sign up for a free Amazon &#8230; <a href="http://www.ab-weblog.com/en/using-the-amazon-product-advertising-api-in-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As I have started with an example of the <a title="Using the eBay Finding API in PHP" href="http://www.ab-weblog.com/en/using-the-ebay-finding-api-in-php/">eBay Finding API</a> in a previous post, I want to continue with the Amazon Product Advertising API now.</p>
<p>Again we need to start with a sign up for a free <a title="Amazon Web Services Website" href="http://aws.amazon.com" target="_blank">Amazon Web Services account</a>. To make money with your Amazon traffic you also need to register for the <a title="Amazon Affiliate Program Website" href="https://affiliate-program.amazon.com" target="_blank">Amazon affiliate program</a>.</p>
<p>Now we can start to build the request URL for the Amazon Product Advertising API:</p>
<pre class="brush: text; gutter: true">http://ecs.amazonaws.com/onca/xml?
	AWSAccessKeyId=%awsAccessKeyId%&amp;
	AssociateTag=%associateTag%&amp;
	ItemPage=%itemPage%&amp;
	Keywords=%keywords%&amp;
	Operation=%operation%&amp;
	ResponseGroup=%responseGroup%&amp;
	SearchIndex=%categoryId%&amp;
	Service=AWSECommerceService&amp;
	Timestamp=%timestamp%&amp;
	Signature=%signature%</pre>
<p>Let&#8217;s see what the individual parameters mean:</p>
<ul>
<li><em>ecs.amazonaws.com:</em> based on the country you want to target, you have to use a <a title="List of Possible Endpoints" href="http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?AnatomyOfaRESTRequest.html" target="_blank">specific endpoint</a>. It is <em>ecs.amazonaws.com</em> for USA.</li>
<li><em>AWSAccessKeyId:</em> you get this access key in your Amazon Web Services account.</li>
<li><em>ItemPage:</em> for the first request you set this to <em>1</em> and increase it in previous requests if you need more items. Each response has up to 10 items (you cannot change that).</li>
<li><em>Keywords:</em> your search keywords. Make sure you use <em>rawurlencode</em> here.</li>
<li><em>Operation:</em> the name of the operation of the Amazon Product Advertising API you want to call. For the keyword search we choose <em><a title="More Info About the Operation ItemSearch" href="http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/ItemSearch.html" target="_blank">ItemSearch</a></em>.</li>
<li><em>ResponseGroup:</em> based on the level of detail you need in the response, choose a useful <a title="List of Response Groups" href="http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/CHAP_ResponseGroupsList.html" target="_blank">response group</a>. For item searches I choose <em>Medium</em> most of the time.</li>
<li><em>SearchIndex:</em> a <a title="List of Search Indices" href="http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?APPNDX_SearchIndexValues.html" target="_blank">search index</a> is a kind of first level category. If you want to search in everything, just choose <em>All</em>.</li>
<li><em>Service:</em> just use <em>AWSECommerceService</em> here.</li>
<li><em>Timestamp:</em>a timestamp generated in PHP like this:
<pre class="brush: php; gutter: false">rawurlencode(gmdate('Y-m-d\TH:i:s\Z'))</pre>
</li>
<li><em>Signature:</em> that&#8217;s the funniest part: please see below how to generate this signature.</li>
</ul>
<p>To be able to send a valid API request, you have to calculate the signature as following:</p>
<pre class="brush: php; gutter: true">$request = "GET\necs.amazonaws.com\n/onca/xml\n";
$request .= "AWSAccessKeyId=%awsAccessKeyId%&amp;AssociateTag=%associateTag%&amp;ItemPage=%itemPage%&amp;Keywords=%keywords%&amp;Operation=%operation%&amp;ResponseGroup=%responseGroup%&amp;SearchIndex=%categoryId%&amp;Service=AWSECommerceService&amp;Timestamp=%timestamp%";
$signature = rawurlencode(base64_encode(hash_hmac('sha256', $request, %secretKey%, true)));</pre>
<p>You get the needed <em>%secretKey%</em> in your Amazon Web Services account, too.</p>
<p>When you&#8217;ve done everything correctly, you can pass the resulting request URL to this small function that we used already for the <a title="Using the eBay Finding API in PHP" href="http://www.ab-weblog.com/en/using-the-ebay-finding-api-in-php/">eBay Finding API</a> request and receive the XML document response of the API:</p>
<pre class="brush: php; gutter: true">/**
 * Returns the SimpleXML object.
 *
 * @param string $url The URL to receive the XML document.
 * @return string The SimpleXML object.
 *
 */
function getXml($url) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_TIMEOUT, 3);
	$result = curl_exec($ch);
	curl_close($ch);

	return simplexml_load_string($result);
}</pre>
<p>Unfortunately I have to say that I think the Amazon Product Advertising API is really confusing and badly documented. Especially if you need to work with these search indices and categories (so-called <em>nodes</em>) that&#8217;s not very funny at all. And there are even things that are not bad, but just wrong documented in the Amazon Product Advertising API documentation.</p>
<p><em>What&#8217;s your opinion about the Amazon Product Advertising API?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/using-the-amazon-product-advertising-api-in-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using the eBay Finding API in PHP</title>
		<link>http://www.ab-weblog.com/en/using-the-ebay-finding-api-in-php/</link>
		<comments>http://www.ab-weblog.com/en/using-the-ebay-finding-api-in-php/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 16:13:39 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[eBay]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=171</guid>
		<description><![CDATA[While working on a client project I needed to connect the website to the eBay Finding API to show eBay items on the website. In the following I want to show how to get eBay items from the eBay Finding &#8230; <a href="http://www.ab-weblog.com/en/using-the-ebay-finding-api-in-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While working on a client project I needed to connect the website to the eBay Finding API to show eBay items on the website.</p>
<p>In the following I want to show how to get eBay items from the eBay Finding API based on a keyword search.</p>
<p>First of all you need to join the free <a title="eBay Developers Program Website" href="http://developer.ebay.com" target="_blank">eBay developers program</a> to get your application ID. If you additionally want to earn some money with your eBay traffic – and probably that&#8217;s the reason why you want to integrate eBay items in your website <img src='http://www.ab-weblog.com/en/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  – you also need to apply to the <a title="eBay Partner Network Website" href="https://publisher.ebaypartnernetwork.com/files/hub/en-US/index.html" target="_blank">eBay partner network</a>.</p>
<p>After you have been registered in the eBay developers program and partner network, you can use following URL in your request to query for eBay items:</p>
<pre class="brush: text; gutter: true">http://svcs.ebay.com/services/search/FindingService/v1?
	OPERATION-NAME=%operationName%&amp;
	SERVICE-VERSION=%serviceVersion%&amp;
	GLOBAL-ID=%globalId%&amp;
	SECURITY-APPNAME=%appId%&amp;
	RESPONSE-DATA-FORMAT=%responseDataFormat%&amp;
	REST-PAYLOAD&amp;
	affiliate.networkId=%networkId%&amp;
	affiliate.trackingId=%trackingId%&amp;
	affiliate.customId=%customId%&amp;
	paginationInput.entriesPerPage=%entriesPerPage%&amp;
	paginationInput.pageNumber=%pageNumber%&amp;
	keywords=%keywords%</pre>
<p>Now let&#8217;s see what the individual parameters mean:</p>
<ul>
<li><em>OPERATION-NAME:</em> the name of the operation of the eBay Finding API you want to call. For the keyword search we choose <em><a title="More Info About the Operation findItemsByKeywords" href="http://developer.ebay.com/devzone/finding/callref/finditemsbykeywords.html" target="_blank">findItemsByKeywords</a></em>.</li>
<li><em>SERVICE-VERSION:</em> the API version you&#8217;re using (the current one is <em>1.0.0</em> right now).</li>
<li><em>GLOBAL-ID:</em> here you need to include the <a title="List of Global ID Values" href="http://developer.ebay.com/DevZone/merchandising/docs/CallRef/Enums/GlobalIdList.html" target="_blank">ID of the eBay site</a> you&#8217;re using.</li>
<li><em>SECURITY-APPNAME:</em> the application ID you got from the eBay developers program website.</li>
<li><em>RESPONSE-DATA-FORMAT:</em> you can choose here how the data should be returned. I use <em>XML</em>, but you also could choose <em>JSON</em> or <em>NV</em> (name-value pair).</li>
<li><em>REST-PAYLOAD:</em> just specify this without a value after the standard headers above.</li>
<li><em>affiliate.networkId:</em> you get this ID from the eBay partner network.</li>
<li><em>affiliate.trackingId:</em> you get this ID from the eBay partner network.</li>
<li><em>affiliate.customId:</em> choose any additional code here you want to use as optional tracking (e. g. for special campaigns).</li>
<li><em>paginationInput.entriesPerPage:</em> here you can choose how many items (maximal 100) are returned per request.</li>
<li><em>paginationInput.pageNumber:</em> for the first request you set this to <em>1</em> and increase it in previous requests if you need more items.</li>
<li><em>keywords:</em> last but not least you include your search keywords here. Make sure you use <em>utf8_decode</em> if the keywords are in UTF-8.</li>
</ul>
<p>Finally we just need to receive our XML data. Therefore I use this simple function to get the data from the URL and load the XML document:</p>
<pre class="brush: php; gutter: true">/**
 * Returns the SimpleXML object.
 *
 * @param string $url The URL to receive the XML document.
 * @return string The SimpleXML object.
 *
 */
function getXml($url) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_TIMEOUT, 3);
	$result = curl_exec($ch);
	curl_close($ch);

	return simplexml_load_string($result);
}</pre>
<p>Of course, there is very much more you can do with the eBay APIs. For example I also needed to get items by category as well as the most watched items. That&#8217;s also pretty easy. If you need more, you can even do the whole buying process directly through the eBay APIs: this way the user does not need to leave your website at all to buy an item.</p>
<p>Finally I want to say that in fact the eBay APIs are very big and complex APIs, but the documentation is quite good, too. There are much worse examples of big APIs (see also my post about the <a title="Using the Amazon Product Advertising API in PHP" href="http://www.ab-weblog.com/en/using-the-amazon-product-advertising-api-in-php/">Amazon Product Advertising API</a>).</p>
<p><em>Did you use the eBay APIs yourself already?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/using-the-ebay-finding-api-in-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->