For a long time, I've been using Jingdong Alliance/Jingdao Fan to recommend books and other kinds of goodies on the Jingdong platform, mainly to introduce and share the experience of such goods, and to get the promotional links or QR codes of the goods, so as to make it convenient for users in need to go to check out and buy.

And one of the biggest problems here is that both the shared link and the QR code have an expiration date of 60 days. After this expiration date, opening is to the Jingdong home page. I also consulted the official customer service on this issue and was told that this is how the platform is set up and there is no better way.

But also got a useful piece of information, that is, in the Jingdong affiliate platform, you can generate a long link to the goods, and the long link will not expire. So I added a custom field to each recommended article in the article publishing backend of my website, i.e.: Jingdong product link. At the same time, in the front-end page, display the link button, and through qrcode.js to generate the link QR code, so that users can scan the code directly to open the mobile Jingdong, directly to the product page.

And this in turn creates a problem: due to the Jingdong Affiliate provides goods long link has more parameters (involving tracking the user to place an order as well as rebate calculation, etc.), resulting in the generation of QR code actually can not be used. The first time I also thought of using a short link generation platform.

If you want to use the long link of Jingdong affiliate in each article of product recommendation, you can automatically convert it into short link by short link generation platform, and then generate QR code and link button in the article page. This is a semi-automated process that requires the use of an API, and third-party short link generation platforms are still limited.

Then build a short connection generation platform! Search the web and find a suitable open source program: Polr

What is Polr?

Polr is a powerful, lightweight and open source short link management system for creating and managing short links. As an open source tool, Polr allows users to freely deploy and customize it, completely free from the limitations of paid services, making it ideal for individual users, small and medium-sized businesses, or teams of developers.

Polr has a lot of nice features, and for my needs, the following are very relevant:

  • Randomized & Customized Short Link Generation

    Support to generate random short links, also can be customized according to the needs of the link suffix.

  • Powerful management features

    Provides complete control over short links, including enabling/disabling, deleting and other operations. Easily manage user rights (if multi-user mode is enabled).

  • API Integration

    Provides a RESTful API for developers to integrate Polr into other applications or automated processes.

Installation Configuration

1, installed the web environment of a server, you can use lnmp, lamp one-click package or pagoda and other panels to build the web environment.
2, a nice short enough domain name with good resolution.

preliminary

Github address:https://github.com/cydrobolt/polr

1. Add website and download program

Add the domain name and go to the root directory of the website and use the following command.

cd /www/wwwroot/website.com
#下载官方源码
git clone https://github.com/cydrobolt/polr.git
mv polr/{.,}* ./

#下载汉化文件(网上流传的汉化版本,无法支持二维码功能,此处博主依据最新版 Polr 自行汉化了一个,功能正常使用。)
cd resources && rm -rf views && wget https://github.com/honorcnboy/Porl-CHN/releases/download/1.0.0/porl_views_1.0.tar.gz
tar zxvf porl_views_1.0.tar.gz
cd ..

2. Download and install composer

#在/root目录下安装Composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

#进入网站根目录运行
cd /www/wwwroot/website.com
composer install --no-dev -o

3. Will .env.setup Create a file named .env duplicate

cp .env.setup .env

4. Website setup

Click on Website - Settings - Pseudo Static in the Pagoda panel and set it to:laravel5Then go to Web Directory - Running Directory and select Then go to Web Directory - Runtime Directory and select/publicand save it. Then go back to Pseudostatic and fill in the following code. At the same time, set up the SSL

# Ngnix
location / {
            try_files $uri $uri/ /index.php$is_args$args;
}

# Apache
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

5. Reboot Nginx / Apache, change the permissions of all files under the site to 777, owner www

6. Go to http://website.com/setup to complete the settings