Extension:AmazonSearch
Release status: beta |
|
|---|---|
| Implementation | Tag |
| Description | embed item link searched by Amazon |
| Author(s) | Kimagurenote (Corytalk) |
| Latest version | 1.1.6 |
| MediaWiki | |
| PHP | 5.4.0+ |
| Database changes | No |
<amazon> |
|
| Licence | Apache License 2.0 |
| Download | https://kimagurenote.net/kn/AmazonSearch#Download https://kimagurenote.net/kn/AmazonSearch#History |
The AmazonSearch extension provides a way to embed shopping links to Amazon in wiki pages.
Installation
[edit]- At first, you must get Amazon associate tag, Product Advertising API (PA-API) key(★) and secret(◆) from Amazon. From US, UK or other region where you want to use it.
- Download zip file from author's website, unzip it and place the file(s) in a directory called
AmazonSearchin yourextensions/folder. - Add the following code at the bottom of your LocalSettings.php file:
require_once "$IP/extensions/AmazonSearch/AmazonSearch.php"; $wgAmazonSearchDefaultMerchantId = 'All'; $wgAmazonSearchDefaultRegion = 'us'; $wgAmazonSearchAPIKey['us'] = '★'; $wgAmazonSearchAPISecret['us'] = '◆'; $wgAmazonSearchAssociateTag['us'] = 'yourtag-20'; $wgAmazonSearchAPIKey['uk'] = '☆'; $wgAmazonSearchAPISecret['uk'] = '◇'; $wgAmazonSearchAssociateTag['uk'] = 'yourtag-21'; $wgAmazonSearchAPIKey['jp'] = '☆'; $wgAmazonSearchAPISecret['jp'] = '◇'; $wgAmazonSearchAssociateTag['jp'] = 'yourtag-22'; ... /* (option) cached data alive time by seconds */ $wgAmazonSearchCachingTime = 43200;
- Add the following code at the bottom of your MediaWiki:Common.css. You can fully customize it. But you will need some permissions if you use MediaWiki 1.32 or above. See: MediaWiki_1.32/interface-admin.
/* Extension:AmazonSearch */
div.amazonsearch {
clear: both;
width: 100%;
margin: 0 auto;
padding: 0.5em;
border: 1px solid #444;
overflow: hidden;
}
div.amazonsearch img.amazonsearchimg {
float: left;
margin: 0.1em 1em 0.1em 0.1em;
}
div.amazonsearch p.amazonsearchname {
margin: 0;
font-size: 90%;
text-indent: 0;
}
div.amazonsearch p.amazonsearchauthor::before {
background-color: #bbb;
border-radius: 10%;
color: #fff;
font-size: smaller;
padding: 0 0.5em 0 0.5em;
margin-right: 0.5em;
content: "Ad";
}
div.amazonsearch p.amazonsearchauthor {
margin: 0;
font-size: 80%;
text-indent: 0;
}
div.amazonsearch ul {
margin: 0;
}
div.amazonsearch ul li {
display: inline-block;
text-align: center;
list-style: none;
font-size: 90%;
width: 12em;
margin: 0.2em;
padding: 0.2em 0.5em 0.2em 0.5em;
border-radius: 0.5em;
white-space: nowrap;
}
div.amazonsearch ul li a {
color: #fff;
}
div.amazonsearch ul li.shoplinkamazon {
background-color: #f90;
}
Done – Navigate to Special:Versionon your wiki to verify that the extension is successfully installed.
Usage
[edit]<amazon>search keyword(s)</amazon>
You can put a link for the top item about "MediaWiki" by Amazon on a wiki page. For example:
<amazon>MediaWiki</amazon>
You can specify some parameters(*). For example:
<amazon SearchIndex="Books">MediaWiki</amazon>
(*) Actor, Artist, Author, Brand, BrowseNodeId, Condition, DeliveryFlags, MaxPrice, Merchant, MinPrice, MinReviewsRating, MinSavingPercent, SearchIndex and SortBy are available. Details see here.
You can put a link to other (non-default) region of Amazon if you get PA-API key and secret of this region and set it. For example:
<amazon region="uk">MediaWiki</amazon>
If this extension put no result, you can find an error message in the source of html. Generally press Ctrl+U to view a source. For example:
<!-- amazon>API call failure.</amazon -->
If you meet Amazon PA-API limit, you will get "API call failure".
Additional Settings
[edit]Caching
[edit](1.1.3+) This extension is able to cache search results with MediaWiki object cache.
This feature will save to call Amazon PA-API, resulting faster and reducing errors.
You can set live time of cached data as seconds, 3600 seconds (1 hour) by default.
$wgAmazonSearchCachingTime = 43200;
(1.1.6+) This extension uses MainStash to improve response if available.
Note: This extension uses MediaWiki ObjectCache mechanism. You must configure $wgMainCacheType and $wgMainStash if already not.
Note: This is a different feature from parser cache (setting). Purge not affect this feature.
Note: You can't clear this cache individually. You can set caching alive time as $wgAmazonSearchCachingTime at your's discretion, but we recommend to set 86400 (1 day) or shorter.
(Not recommended) If you wan't use caching, set as follows.
$wgAmazonSearchCachingTime = false;
No Operation
[edit](1.1.6+) You can pause this function temporally when Amazon PA-API failure and so on.
$wgAmazonSearchNoOperation = true;
Failed Relay
[edit](1.1.6+) You can relay search keywords automatically to Extension:YJShopping when Amazon PA-API failure.
This extension put no result if meets Amazon PA-API errors if this feature not active.
If you want to use this feature, you must install and configure Extension:YJShopping also.
$wgAmazonSearchFailedRelay = "wfRenderYJShopping";
Note: This feature will relay keyword(s) only. Without other parameters e.g. SearchIndex, Artist and so on.
Note: You can redirect always without calling Amazon PA-API with "No Operation" also.
PA-API v5
[edit]It was supported new PA-API v5 since Mar 02, 2020 (at v1.1.0).
Former PA-API v4 will been discontinued soon. Please update to new code but you may not need to change any configuration (LocalSettings.php).
If it not work fine with PA-API v5, try to use new Scratchpad, and renew your AccessKey and SecretKey.
See details, Migration Guide.
Beta
[edit]The author tested it and worked fine with Amazon.co.jp (Amazon Japan) on MediaWiki 1.32. But I can't test it for other region because I can't get PA-API key and secret.
If you want to use Amazon PA-API, you must offer 3 or more sales in this region with official linking tools via your Associate tag, and you must pass to review your website by Amazon.
Please test it in other region if you can. Thank you.
Notice
[edit]Limit of the Amazon PA-API is so hard(T_T)
You will unable to use Amazon PA-API someday if you can't make sales continuously. [1]
If you want to use it in Japan, you can use YJShopping extension instead.
See also
[edit]- AmazonSearch (author site, written in Japanese)
- Extension:YJShopping - embed multi links by Yahoo! JAPAN API
- Amazon Product Advertising API (PA-API)
