<?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>King Kludge &#187; api</title>
	<atom:link href="http://www.kingkludge.net/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kingkludge.net</link>
	<description>Husband, father, hacker, maker. Addicted to all things geeky, especially robots.</description>
	<lastBuildDate>Wed, 28 Sep 2011 14:18:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Facebook performance woes</title>
		<link>http://www.kingkludge.net/2009/12/facebook-performance-woes/</link>
		<comments>http://www.kingkludge.net/2009/12/facebook-performance-woes/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 17:42:15 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Yahoo!]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.kingkludge.net/2009/12/facebook-performance-woes/</guid>
		<description><![CDATA[Today Facebook launched their new privacy settings and forced all their users to update their settings. We noticed at Yahoo! that we were started to get lots of timeouts from Facebook&#8217;s APIs that we use on the Yahoo! homepage. I&#8217;ve &#8230; <a href="http://www.kingkludge.net/2009/12/facebook-performance-woes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today Facebook launched their new privacy settings and forced all their users to update their settings.</p>
<p>We noticed at Yahoo! that we were started to get lots of timeouts from Facebook&#8217;s APIs that we use on the Yahoo! homepage.</p>
<p>I&#8217;ve not heard anything official from Facebook yet, so this next part is all speculation.</p>
<p>I suspect that as a user updates their privacy settings, as forced to the first time they hit facebook.com now, Facebook flags that users account is dirty (something changed) and purges the cache of the users stream data.<br />
Now that the cache is empty for a particular user, when a friend of that user views Facebook, the backend servers must go back to the master data source and confirm permissions on what is visible before it is displayed. </p>
<p>That is fine when you have a few users updating their permissions, if however you force ALL your users to do this, you site rapidly becomes overwhelmed, as you effectively removed your cache. This effect is known as &#8220;The Thundering Herd&#8221;.</p>
<p>As the load increases, due to all extra requests for data that would normally be handled by caches, you start to get race conditions as requests return and try to populate the cache. Also as the load increases, requests start to take longer as connections are kept open while backends are queried. Because connections are being kept open, the server stops handling requests, as there are no more connection slots and you start to get errors as clients can no longer connect.</p>
<p>How do you prevent this. Don&#8217;t push changes that require you whole userbase to update their records at once. Stage the release, starting with 1% until you can guage how much load it will generate on your servers. Then you can safely ramp up your change safely.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kingkludge.net/2009/12/facebook-performance-woes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tesco TJam</title>
		<link>http://www.kingkludge.net/2009/08/tesco-tjam/</link>
		<comments>http://www.kingkludge.net/2009/08/tesco-tjam/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 20:11:53 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[tesco]]></category>

		<guid isPermaLink="false">http://www.kingkludge.net/2009/08/tesco-tjam/</guid>
		<description><![CDATA[So this evening I attended Tesco&#8217;s TJam event held at Microsoft&#8217;s London Customer Centre at Victoria. Tesco is starting the rollout of it&#8217;s new backend Grocery application, code named Martini (anytime, anyplace, anywhere). They have opened up their new APIs &#8230; <a href="http://www.kingkludge.net/2009/08/tesco-tjam/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So this evening I attended Tesco&#8217;s TJam event held at Microsoft&#8217;s London Customer Centre at Victoria.</p>
<p>Tesco is starting the rollout of it&#8217;s new backend Grocery application, code named Martini (anytime, anyplace, anywhere).<br />
They have opened up their new APIs from their grocery service to a few select developers. In fact very select, you had to attend to launch/briefing in person to register for the scheme.</p>
<p>A lot of time had obviously gone into preparing the event. With almost the whole conference room covered in brainstorm sheets and post it notes. These covered 5 main areas for potential developers to concentrate on or consider for their application. This was based on market and socioethnic research (hey that may not be the correct word but I didn&#8217;t write it down and I&#8217;m now on the train).</p>
<p>After an initial introduction, we were all invited to chow down on pizza, lager and wine (actually nice for change to get red and white wine available) and browse the brainstormings, only slightly hindered by Microsoft&#8217;s insistence that no one take food or drink into their meeting rooms.</p>
<p>The APIs look reasonably well thought out and the new Martini release adds some great new functionality, such as nutrition information and cheaper alternatives to products in your shopping basket.</p>
<p>There were some concerns voiced by some developers present at the briefing, quite rightly, over their security implementation, which requires the API consumer to forward the users login credentials, rather than implementing OAuth or another signature/token based authentication mechanism.<br />
It looks like this will probably be addressed in a future release, once Martini is live and running Tesco&#8217;s existing shopping site.<br />
Customer basket checkout has yet to) be finalised, due to financial and legal compliance.</p>
<p>Everyone who attended the event and wishes to participate in the affliate scheme will get signed up to TradeDoubler and will earn £5 for each new customer they manage to entice into signing up to Tesco&#8217;s online shopping service.<br />
The tricky part of this is then the ongoing revenue.<br />
For each basket purchased over the value of £50 the application developer gets a potential £0.10. Potential, as this is the proportional to the number of products added to basket by that particular application versus the total number of products in the basket.<br />
Note also products in basket not items. 10 one penny chews would earn you the same as someone adding an iPhone or flatscreen tv. This is deliberate, to prevent skewing of apps towards higher value goods.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kingkludge.net/2009/08/tesco-tjam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-JAM and the Tesco Grocery API</title>
		<link>http://www.kingkludge.net/2009/08/t-jam-and-the-tesco-grocery-api/</link>
		<comments>http://www.kingkludge.net/2009/08/t-jam-and-the-tesco-grocery-api/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 22:36:13 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[shopping]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[tesco]]></category>
		<category><![CDATA[tjam]]></category>

		<guid isPermaLink="false">http://www.kingkludge.net/2009/08/t-jam-and-the-tesco-grocery-api/</guid>
		<description><![CDATA[Finally found something I can talk about openly. Having spent so long working on commercially sensitive applications, which is now in the open. Anyway, apart from helping the Yahoo! OpenHack day, I also signed up to Tesco&#8217;s T-JAM event which &#8230; <a href="http://www.kingkludge.net/2009/08/t-jam-and-the-tesco-grocery-api/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Finally found something I can talk about openly.</p>
<p>Having spent so long working on <a href="http://www.kingkludge.net/2009/08/new-yahoo-homepage/">commercially sensitive applications</a>, which is now in the open.</p>
<p>Anyway, apart from helping the Yahoo! OpenHack day, I also signed up to <a href="http://techfortesco.blogspot.com/2009/08/two-days-until-tjam.html">Tesco&#8217;s T-JAM event</a> which certainly looks like it could be interesting.</p>
<p>Tesco&#8217;s API is a SOAP API, written in and for C# primarily, so it seems that some people had some issues getting started in PHP.</p>
<p>There is a revised API in the pipeline and also the addition of a REST API as well.</p>
<p>But here are some handy hints for getting started:</p>
<p>First off, PHP 5+ has a SOAP client (and server) built in, so here&#8217;s a quick script that generates a valid login to the TESCO dev API.</p>
<pre class="prettyprint">&lt;?php
define('SOAPSERVER', 'http://www.lansley.com/TescoAPI/TescoAPI.svc?wsdl');
define('DEV_KEY', 'your dev key');
define('APP_KEY', 'your app key');

$user  = 'email address of test user';
$pass  = 'password of test user';
$tesco = new SoapClient(SOAPSERVER);

$params = array(
                'email'          =&gt; $user,
                'password'       =&gt; $pass,
                'developerKey'   =&gt; DEV_KEY,
                'applicationKey' =&gt; APP_KEY
              );
$sess = $tesco-&gt;__soapCall('Login', array('parameters' =&gt; $params));
print_r($sess);</pre>
<p>Which generates the following output:</p>
<pre class="commandline">stdClass Object
(
    [LoginResult] =&gt; stdClass Object
        (
            [StatusCode] =&gt; 0
            [StatusInfo] =&gt;
        )

    [session] =&gt; stdClass Object
        (
            [ApplicationKey] =&gt; your app key
            [BranchNumber] =&gt; 2055
            [Cookies] =&gt; stdClass Object
                (
                    [string] =&gt; Array
                        (
                            [0] =&gt; sessionTest=
                            [1] =&gt; v=WggAACp8E%3d%3d
                            [2] =&gt; CustomerId=9xxx9
                            [3] =&gt; CID=93
                            [4] =&gt; BTCCMS=h1qzwp%c%3d
                            [5] =&gt; UIMode=00000
                            [6] =&gt; PS=CSC=D
                            [7] =&gt; SSVars=CustomerName=Bob&amp;basketTotal=&amp;basketCount=&amp;slotStart=&amp;slotEnd=&amp;addrName=
                            [8] =&gt; u=oQgttVAeDK%2bg%3d%3d
                            [9] =&gt; t=dgcAA28XbJWE%3d
                        )

                )

            [CustomerName] =&gt; Bob
            [DeveloperKey] =&gt; your dev key
        )

)</pre>
<p>I&#8217;ve monkeyed around with the values in some of the keys (as these are my login credentials) but you can see the general structure. The session object needs to be stored and used in subsequent requests.</p>
<p>To interrogate the API and view the functions and types available, there are some PHP functions to help:</p>
<pre class="prettyprint">&lt;?php
define('SOAPSERVER', 'http://www.lansley.com/TescoAPI/TescoAPI.svc?wsdl');
define('DEV_KEY', 'your dev key');
define('APP_KEY', 'your app key');

$tesco = new SoapClient(SOAPSERVER);

print_r($tesco-&gt;__getFunctions());</pre>
</p>
<p>Which shows the following SOAP methods available:</p>
<pre class="commandline">Array
(
    [0] =&gt; LoginResponse Login(Login $parameters)
    [1] =&gt; LogEventResponse LogEvent(LogEvent $parameters)
    [2] =&gt; ProductSearchResponse ProductSearch(ProductSearch $parameters)
    [3] =&gt; ListProductOffersResponse ListProductOffers(ListProductOffers $parameters)
    [4] =&gt; ListProductCategoriesResponse ListProductCategories(ListProductCategories $parameters)
    [5] =&gt; ListProductsByCategoryResponse ListProductsByCategory(ListProductsByCategory $parameters)
    [6] =&gt; SetProductRatingResponse SetProductRating(SetProductRating $parameters)
    [7] =&gt; GetProductRatingResponse GetProductRating(GetProductRating $parameters)
    [8] =&gt; GetMultipleProductRatingsResponse GetMultipleProductRatings(GetMultipleProductRatings $parameters)
    [9] =&gt; ListBasketItemsResponse ListBasketItems(ListBasketItems $parameters)
    [10] =&gt; AddItemToBasketResponse AddItemToBasket(AddItemToBasket $parameters)
    [11] =&gt; ChangeItemQuantityResponse ChangeItemQuantity(ChangeItemQuantity $parameters)
    [12] =&gt; DeleteItemFromBasketResponse DeleteItemFromBasket(DeleteItemFromBasket $parameters)
)</pre>
<p>And:</p>
<pre class="prettyprint">&lt;?php
define('SOAPSERVER', 'http://www.lansley.com/TescoAPI/TescoAPI.svc?wsdl');
define('DEV_KEY', 'your dev key');
define('APP_KEY', 'your app key');

$tesco = new SoapClient(SOAPSERVER);

print_r($tesco-&gt;__getTypes());</pre>
</p>
<p>Which shows the following types available:</p>
<pre class="commandline">Array
(
    [0] =&gt; struct ArrayOfstring {
 string string;
}
    [1] =&gt; struct ResponseStatus {
 int StatusCode;
 string StatusInfo;
}
    [2] =&gt; struct Session {
 string ApplicationKey;
 string BranchNumber;
 ArrayOfstring Cookies;
 string CustomerName;
 string DeveloperKey;
}
    [3] =&gt; struct ArrayOfProduct {
 Product Product;
}
    [4] =&gt; struct Product {
 string Id;
 string ImagePath;
 string Name;
 string OfferPromotion;
 string OfferValidity;
 double Price;
 int Quantity;
 float Rating;
}
    [5] =&gt; struct ArrayOfCategory {
 Category Category;
}
    [6] =&gt; struct Category {
 ArrayOfCategory Children;
 string Href;
 string Id;
 string Name;
 string RawHtml;
}
    [7] =&gt; struct ProductRating {
 string Id;
 int MyRating;
 float Rating;
 int Rating1Count;
 int Rating2Count;
 int Rating3Count;
 int Rating4Count;
 int Rating5Count;
}
    [8] =&gt; struct Login {
 string email;
 string password;
 string developerKey;
 string applicationKey;
}
    [9] =&gt; struct LoginResponse {
 ResponseStatus LoginResult;
 Session session;
}
    [10] =&gt; struct LogEvent {
 Session session;
 string eventText;
}
    [11] =&gt; struct LogEventResponse {
 ResponseStatus LogEventResult;
}
    [12] =&gt; int char
    [13] =&gt; duration duration
    [14] =&gt; string guid
    [15] =&gt; struct ProductSearch {
 Session session;
 string searchString;
 boolean getRatings;
}
    [16] =&gt; struct ProductSearchResponse {
 ResponseStatus ProductSearchResult;
 ArrayOfProduct products;
}
    [17] =&gt; struct ListProductOffers {
 Session session;
 boolean getRatings;
}
    [18] =&gt; struct ListProductOffersResponse {
 ResponseStatus ListProductOffersResult;
 ArrayOfProduct offers;
}
    [19] =&gt; struct ListProductCategories {
 Session session;
}
    [20] =&gt; struct ListProductCategoriesResponse {
 ResponseStatus ListProductCategoriesResult;
 ArrayOfCategory categories;
}
    [21] =&gt; struct ListProductsByCategory {
 Session session;
 Category shelf;
 boolean getRatings;
}
    [22] =&gt; struct ListProductsByCategoryResponse {
 ResponseStatus ListProductsByCategoryResult;
 ArrayOfProduct products;
}
    [23] =&gt; struct SetProductRating {
 Session session;
 Product product;
}
    [24] =&gt; struct SetProductRatingResponse {
 ResponseStatus SetProductRatingResult;
}
    [25] =&gt; struct GetProductRating {
 Session session;
 Product thisproduct;
}
    [26] =&gt; struct GetProductRatingResponse {
 ResponseStatus GetProductRatingResult;
 ProductRating productrating;
}
    [27] =&gt; struct GetMultipleProductRatings {
 Session session;
 string spaceDelimitedProductIDs;
}
    [28] =&gt; struct GetMultipleProductRatingsResponse {
 ResponseStatus GetMultipleProductRatingsResult;
 string productRatingsInfo;
}
    [29] =&gt; struct ListBasketItems {
 Session session;
}
    [30] =&gt; struct ListBasketItemsResponse {
 ResponseStatus ListBasketItemsResult;
 ArrayOfProduct products;
}
    [31] =&gt; struct AddItemToBasket {
 Session session;
 Product item;
}
    [32] =&gt; struct AddItemToBasketResponse {
 ResponseStatus AddItemToBasketResult;
}
    [33] =&gt; struct ChangeItemQuantity {
 Session session;
 Product item;
}
    [34] =&gt; struct ChangeItemQuantityResponse {
 ResponseStatus ChangeItemQuantityResult;
}
    [35] =&gt; struct DeleteItemFromBasket {
 Session session;
 Product item;
}
    [36] =&gt; struct DeleteItemFromBasketResponse {
 ResponseStatus DeleteItemFromBasketResult;
}
)</pre>
<p>Hope this helps, not just with the Tesco Grocery API, but in general debugging SOAP calls from within PHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kingkludge.net/2009/08/t-jam-and-the-tesco-grocery-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

