flagrow/amazon-affiliation
Composer 安装命令:
composer require flagrow/amazon-affiliation
包简介
Add your Amazon Affiliation tag to Amazon links
README 文档
README
A Flarum extension that automatically adds your Amazon Associates affiliate tag to Amazon links posted on your forum, so eligible purchases earn you commission — no need to ask your users to format links a particular way.
How it works
Whenever a post is rendered, every Amazon link in it is rewritten on the fly:
- The link is normalised to
https://with thewww.subdomain. - Your configured affiliate tag for that marketplace is appended as the
tagquery parameter (or replaces an existing one, depending on your settings). - Links to Amazon marketplaces you haven't configured are left alone (or have their tag stripped, if you enable that).
Rewriting happens at render time, so changing your tag updates every existing post automatically — nothing is baked into the stored content.
A separate tag is configured per marketplace (.com, .co.uk, .de, .fr, …), because Amazon Associates accounts are region-specific. Leave a marketplace blank to skip it.
Note: Shortened Amazon share links (
amzn.to,a.co) are not rewritten. These point to a redirect service rather than a marketplace domain, so the real product URL — and therefore the marketplace and tag — can't be determined without following the redirect. Post the fullamazon.<tld>URL to have your tag applied.
Features
- Per-marketplace tags — configure a distinct affiliate tag for each Amazon region.
- Keep or replace existing tags — by default an existing
tagin a link is replaced with yours; optionally keep the original instead. - Strip tags on uncovered marketplaces — optionally remove affiliate tags from links to marketplaces you haven't configured, so no one else's tag survives.
- URL normalisation —
http→httpsand bare hosts gain thewww.subdomain. - Product cards — Amazon product URLs become a compact card linking to the tagged product page (see below).
Installation
composer require fof/amazon-affiliation:"*"
Then enable FoF Amazon Affiliation in your admin panel and configure your affiliate tags.
Updating
composer update fof/amazon-affiliation php flarum cache:clear
Configuration
All settings live on the extension's page in the admin panel.
| Setting | Description |
|---|---|
| Affiliate Tags | One field per Amazon marketplace (amazon.com, amazon.co.uk, …). Enter the affiliate tag for each region you want covered. Leave blank to ignore that marketplace. |
| Keep existing tags | When enabled, a link that already carries a tag keeps it; otherwise your configured tag replaces it. |
| Remove tags on uncovered links | When enabled, links to marketplaces you haven't configured have any existing tag stripped. By default such links are left untouched. |
Product cards
Amazon product URLs (/dp/… and /gp/product/…) are turned into a compact, self-contained product-link card instead of a plain link. The card links straight to the canonical product URL carrying your affiliate tag, so the click is attributed to your account.
This replaces the old MediaEmbed iframe embed. s9e\TextFormatter removed its built-in Amazon site, and the Amazon affiliate iframe widget it relied on was retired by Amazon in 2022 (it renders blank). A tagged product link is the mechanism Amazon still supports, so the card is built from that. Posts authored under older versions of this extension — whose embeds were stored as MediaEmbed tags — automatically render as cards too.
A couple of things to be aware of:
- Cards always use your configured tag for the marketplace — the "keep existing tags" setting only applies to plain (non-product) links.
- All marketplaces are supported, including CN, BR, MX and AU. (The old iframe embed couldn't handle those; the card builds a plain tagged link, so they work too.)
- Prefer plain links? Turn off Display Amazon product links as a rich product card in the settings and product URLs stay plain links, tagged like any other Amazon link.
Links
统计信息
- 总下载量: 103
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-05-23