Go to main content

Textpattern CMS support 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
Archived 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
Archived 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

#11 2005-06-14 15:19:17

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

Re: asv_amazon

oh ok…yeah the result I get from Amazon is an xml file which I store locally and then parse

Offline

#12 2005-06-14 20:09:43

davidm
Member
From: Paris, France
Registered: 2004-04-27
Posts: 719

Re: asv_amazon

I am interrested by this plugin, which I missed at the time, but my question is : will it be possible to use this plugin with european amazon websites, such as amazon.fr ?

Thx !


.: Retired :.

Offline

#13 2005-06-14 20:44:34

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

Re: asv_amazon

yeah that’s built in to the plugin…you can specify which locale to use. By default it is set to US, but you can set locale to any of the following:
  1. us – United States
  2. uk – United Kingdom
  3. de – Denmark
  4. jp – Japan
  5. fr – France
  6. ca – Canada

If you install the plugin you can check out the help section and learn how to use it before activating it.

Offline

#14 2005-06-14 21:10:13

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

Re: asv_amazon

Real quick everyone…just updated my plugin to fix a defect I found. The link at the top is updated to point to version 0.3. Also, the plugin can now be installed using the preferred installer and not the old way of uploading the txt file.

Offline

#15 2005-06-26 18:26:04

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

Re: asv_amazon

this is a nice plugin however….

i was wondering if two things could be done:

1) add an extensions tab – within this the ability to select a product from amazon using some sort of linked search facility within txp to amazon – and to be able to set settings such as the locale, an amzon id if applicable and what type of image, attributes etc.

2) the ability to shorten the title output to x amount of characters. Not sure if I can use the substr plugin in this regard but, for example: Fear and Loathing on the Campaign Trail ’72 (Harper Perennial Modern Classics S.) is a fairly long title for a fixed width column of 250px, so if it would wrap at least it would be good. Not sure if it does wrap, my sites a bit off right now.

thanks for this!

Offline

Board footer

Powered by FluxBB