Textpattern Forum

You are not logged in. Register | Login | Help

#1 2005-05-25 16:50:18

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

asv_amazon

So here we go. I just uploaded my first plugin. I hope people find it useful, and definitely let me know about defects and enhancements. I’ll work on defects right now and make a list of enhancements to review.

Name: asv_amazon
Version: 0.3
Author: Amit Varia
Author URL: <a href=“http://www.amitvaria.com/”>http://www.amitvaria.com/</a>
Modified: 2005-05-25
<a href=“http://www.amitvaria.com/plugin/asv_amazon_0.3.txt”>Download URL</a>
<a href=“http://www.amitvaria.com/index.php?id=67”>Example URL</a>

Summary: You can include some basic information about a product off the Amazon website and now you can cache the product on to your textpattern site.

UPDATE (06/14/2005): I fixed a defect that prevented the plugin from pulling the data from a cached page. Also the plugin can be installed using the 1.0 standard.

Last edited by variaas (2005-06-14 21:07:53)

Offline

#2 2005-05-25 17:40:54

sekhu
Member
Registered: 2005-05-12
Posts: 428
Website

Re: asv_amazon

hey variaas you may want to take a look at this article:

http://aaugh.com/imageabuse.html

would you be able to add such variables to an image and how it’s displayed? Just curious. Very cool article.

Offline

#3 2005-05-25 17:45:45

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: asv_amazon

Sekhu:

Seems like an interesting article. I’ll take a look at it and see if it works for things other than just CD covers. It’ll definitely put it on my list.

Thanks!

Offline

#4 2005-05-26 23:13:51

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: asv_amazon

I don’t know how many people are considering this plugin useful, but I’m working on the next version right now and am going to start caching. I’m trying to figure out how much to cache.

Should I just cache the XML file that holds all the data about the product, or should I also cache images instead of pulling the image off Amazon’s site?

Offline

#5 2005-05-27 09:22:06

ruairi
Plugin Author
From: Madrid, Spain
Registered: 2005-04-05
Posts: 17
Website

Re: asv_amazon

Hi variaas,

I’m caching the response I get from amazon in rmc_audioscrobbler, here’s the caching code:

<code>
<pre>
if (!file_exists($cachefile)) { $searchResult = $AS->DoKeywordSearch($searchterm, ‘lite’, ‘music’, 1); if ($searchResult) { $result = $searchResult0; $handle = fopen($cachefile, “w”); fwrite($handle, serialize($result)); fclose($handle); }
} else { $cachefilesize = filesize($cachefile); $handle = fopen($cachefile, “r”); $result = unserialize(fread($handle, $cachefilesize));
}
</pre>
</code>

I save the response I get from amazon by simply serializing the object I get from parsing the XML. Works perfectly (for me).

I wouldn’t worry about caching the images, to be able to cache them you’d have to retrieve the images first and save them onto your filesystem (might be more trouble than it’s worth, but if you plan to do so let me know if you need a helping hand).

Last edited by ruairi (2005-05-27 09:25:00)

Offline

#6 2005-05-27 13:44:48

kennethlove666
Member
From: arkansas
Registered: 2004-04-27
Posts: 107
Website

Re: asv_amazon

this doesn’t add in associate IDs, does it? so you’d get a referal and % back on each purchase through your site?


Listen to Kenneth

Offline

#7 2005-05-27 17:25:06

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: asv_amazon

ruairi,

Thanks for the input on caching. I went ahead and wrote it last night, and it’s really close to your code. The only difference is that I don’t serialize the XML received. Is there a reason to serialize it? I just copy the file from the Amazon Website to the “textpattern/tmp” folder.

Also I went and ahead and gave the option to cache the image to the tmp folder as well. Again I just copy the image to the tmp folder.

Offline

#8 2005-05-27 17:26:19

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: asv_amazon

kenneth,

I just have a developer token right now, so I don’t get any kickbacks. I wonder if you need to do anything special to get an associate ID.

Offline

#9 2005-05-28 23:59:48

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: asv_amazon

UPDATE!

I added the ability to cache responses from Amazon’s site in to your textpattern/tmp folder so you don’t have to keep fetching from the Amazon site. The link above has been updated.

Offline

#10 2005-06-14 14:38:41

ruairi
Plugin Author
From: Madrid, Spain
Registered: 2005-04-05
Posts: 17
Website

Re: asv_amazon

variaas wrote:
ruairi,
Thanks for the input on caching. I went ahead and wrote it last night, and it’s really close to your code. The only difference is that I don’t serialize the XML received. Is there a reason to serialize it? I just copy the file from the Amazon Website to the “textpattern/tmp” folder.

The only reason I serialize the result is because the Amazon search api returns an array, I’ve no xml file to cache.

Offline

Board footer

Powered by FluxBB