Following the suggestion given in this thread, I have been trying to redo my review pages to use REST parsed by Magpie instead of the Amazon plugin, since {amazon_price} isn’t working for the plugin. However, I have some Magpie questions.
1) Can I use custom fields (to fetch the ASIN, locale and associate ID associated with each review) within the url fed to magpie? Currently, I have the following code, which at the moment returns nothing:
2) When Magpie has parsed the result of a REST query (see here
for an example, can I then pull in any of the data in that feed using {<variable>}, or can I only use those variables that are defined by the Magpie plugin? For example, can I use {ListPrice} and {SalesRank} right off, without writing any more code to fetch those particular fields? And if I can pull them in, can I test for them using conditionals, to see if they’re present for a particular item?
As you know, my REST example isn’t working totally…but, way back when I was first setting it up, I could pull/display any of the variables returned by either the “lite” or “heavy” versions. In examing the XML returned by your link, nothing is identified…<title>, <price>, etc….I think that’s the problem. —————
If you plug in this REST url…(I’ve broken the urls and other long lines for display here in the forum)... http://xml.amazon.com/onca/xml3?t=webservices-20&dev-t=amznRss&KeywordSearch=weblog&mode=books&bcm=&type=lite
&page=1&ct=text/xml&sort=+salesrank&f=http://xml.amazon.com/xsl/xml-rss091.xsl
You’ll get this back… <rss version=“0.91”>
<channel>
<title>
Amazon.com - Search Results for “weblog” in books
</title>
<link>
http://www.amazon.com/exec/obidos/external-search
?mode=books&keyword=weblog&rank=%2Bsalesrank&tag=amznRss
</link>
<description>
Up-to-date listings of Amazon.com’s top items (by Sales Rank).
</description>
<language>en-us</language>
<docs>
http://www.amazon.com/exec/obidos/subst/xs/syndicate.html
</docs>
<image>
<title>Amazon.com—Earth’s Biggest Selection</title>
<url>http://images.amazon.com/images/G/01/rcm/logo2.gif</url>
<width>120</width>
<height>30</height>
<link>http://www.amazon.com</link>
</image>
<item>
<title>
Blog : Understanding the Information Reformation That’s Changing Your World
</title>
<description>
Blog : Understanding the Information Reformation That’s Changing Your World,
by Hugh Hewitt—$13.99
</description>
<link>
http://www.amazon.com/exec/obidos/ASIN/078521187X/ref=nosimRss/webservices-20
?dev-t=amznRss
</link>
</item>
ETC… —————
The section identifiers are there and I think that’s what Magpie needs…Just my guess.
Don’t know what the problem with yours (or my other one is) that those aren’t being returned though. —————
Edit…In my sample page, the individual book title and link are being displayed. None of the channel stuff is though.
Odd that the URLs would return such different results. I got mine off one of Amazon’s help pages on REST, which one would have hoped would be updated, but that doesn’t seem to have been the case.
I’ll give tweaking yours to single-item a try as well, to see if that at least produces the same results as you have. That should allow me to determine whether I can use {<fieldname>} in the URL to pull in data.
I do wonder if it is a Magpie or an Amazon issue. I imagine you hadn’t actually done any changes just before it broke, though? That’d suggest its Amazon.
Uhhhhh…Never Mind...
Weird, I just plugged your link into Firefox and it now returns with the complete xml tags instead of just plain text all run together.
Oh, it didn’t display right at all for you to start with? I saw the tags all along, but they’re differently named than in your example. Or maybe that’s just the ‘heavy’ bit? Curious that it wouldn’t include a basic item link, like yours, though.
One thing I do notice is that the very first line in my returned info starts… <rss version=“0.91”>
Whereas your’s is…(broke it in two for Forum dispaly)... <ProductInfo xsi:noNamespaceSchemaLocation=
“http://xml.amazon.com/schemas3/dev-heavy.xsd”> —————
Notice mine identifies it as RSS which Magpie reads.
That does seem to be part of it. I altered my URL, to add in ct=text/xml and f=http://xml.amazon.com/xsl/xml-rss091.xsl from yours. However, even with heavy specified, it then only returns the same amount as it does with lite. I wonder if one could change the rss091.xsl bit to get more info ... need to see if they cover that on Amazon’s site.
From what I remember, it’s strictly the heavy/lite designation that determines what’s returned. Don’t think the RSS version has anything to do with that. ——-
Edit: Have you Googled “Amazon REST” or “Amazon RSS” or “Amazon API”?
I remember there were several tutorials out there that were much easier to figure out than reading the Amazon specs.
Some poking around suggests that http://xml.amazon.com/xsl/xml-rss091.xsl is an XSL template, used to transform the raw XML. I wonder if this particular template ignores the extra fields available in the heavy format. If I understand things correctly, it should be possible to write an XSL template of one’s own and use that to parse the XML. If one knows anything about XML, that is.
Might be that Amazon as some more hidden somewhere, though.
Edited to add: Haven’t found any useful tutorials yet (not for my level, at least), but did find another thread here on the forum that discusses modifying the XSL to include more data: http://expressionengine.com/forums/viewthread/10447/
With the help of the other thread, I put up a slightly modified xsl file on my site, and it looks like it should be possible to tweak it to get the data I want from the heavy feed.
However, it does look like the URL fed to magpie can’t take variables. Can anyone confirm if this is the case, or if I am just doing something wrong? This is what I’ve got now:
The PHP works…pretty basic but just plugged it in in this form…without the CSS…PHP on input… {exp:weblog:entries weblog=“amazon_products” status=“open” orderby=“title” sort=“asc”}
<?php
$url = “”;
$amazonNumber = ‘{asin_number}’;
$first = ‘http://xml.amazon.co.uk/onca/xml3?t=webservices-20&dev-t=amznRss&KeywordSearch=’;
$last = ‘&mode=books&bcm=&type=lite&page=1&ct=text/xml&sort=+salesrank&f=http://xml.amazon.co.uk/xsl/xml-rss091.xsl’;
$amazonUrl = $first.$amazonfeed.$last;
echo $amazonUrl.”<br />”
?>
{/exp:weblog:entries} ——-
It returns the ASIN number from my Amazon weblog and the url info for getting to that product (raw format, not a link).
Turns out the problem was that I had the locale stored as UK and US, and the caps caused a problem. So, its doable to put together the URL for Magpie from the contents of various custom fields, without the need for assigning variables or php (although it could no doubt clean up the rather lengthy URL).
However, after all that work, it appears that the main issue (for me, anyway) is the limitations of Magpie and the RSS format. I tried modifying the XSL file to make use of additional fields, but no go.
I then found this thread which notes that only a limited number of fields will be available to hold data from the XML field, since Magpie will only read standard RSS fields (title, link, description, about, creator, subject, summary). To make use of the info in the heavy feed, I’d need quite a few more. It is also awkward not to be able to name the fields more descriptive things instead of being stuck using {about} to get an image URL.
I guess what one would need is a dedicated plugin after all, which parses either the raw XML right off or the XSL ‘styled’ XML without being limited to standard RSS fields and fieldnames.
But at least I learned a bit about XML and XSL in the process.
I’m not sure that that’s right….
How I got into the whole thing is a friend is a manufacturer’s rep (and one of his lines is a client). He gets all his clients on Amazon (knows all the buyers for his category)...he needed a way to check all his product lines every morning, verify stock, user recommendations/reviews, ranking within their product category, etc.
I never used XSL. It was all REST. It worked well. —————
Now, I haven’t dealt with it since then, other than this friend and I go to coffee every morning. They have now taken everything off Amazon…well not really…they have set themselves up as Amazon merchants rather than Amazon itself. They get more money in return, and don’t have to put up with the Amazon system. Amazon’s system works really well for Books and Video cassettes, doesn’t work well for anything else unless you (as a manufacturer control it, ship direct yourself, use your own shipping vendor, control your own inventory, etc.). If you start dealing with them outside their expertise, Amazon is one F@#!*-up outfit. Three times a week I hear a 30 min. rant on Amazon. I’m surprised they are still in business. Books, Videos/DVDs, fine. Everything else, hosed to the Nth degree. —————
Rant over. —————
Bottom line, you shouldn’t need to deal at all with XSL.
But if the URL fed to Magpie doesn’t include a link to an xsl file, then you get what my original link produced: raw xml.
However, I imagine that if one was writing an application to make use of that data without using Magpie to parse it, then yes, one would use the raw xml. First parsing it to xsl would, it seems, be a waste of time.
At least, that’s how I understand it. But it is well past midnight here, so mistakes are definitely possible.