fof/amazon-affiliation 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fof/amazon-affiliation

Composer 安装命令:

composer require fof/amazon-affiliation

包简介

Add your Amazon Affiliation tag to Amazon links

README 文档

README

License Latest Stable Version Total Downloads OpenCollective

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 the www. subdomain.
  • Your configured affiliate tag for that marketplace is appended as the tag query 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 full amazon.<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 tag in 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 normalisationhttphttps and bare hosts gain the www. 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

fof/amazon-affiliation 适用场景与选型建议

fof/amazon-affiliation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.44k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 08 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「amazon」 「extension」 「links」 「affiliation」 「flarum」 「fof」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 fof/amazon-affiliation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fof/amazon-affiliation 我们能提供哪些服务?
定制开发 / 二次开发

基于 fof/amazon-affiliation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 23
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-07