pean/wash

小型URL缩短器

dev-master 2016-05-14 07:33 UTC

This package is not auto-updated.

Last update: 2024-09-28 16:41:31 UTC


README

Wash 是一个小型 URL 缩短器 Composer 包,它将存储一个 URL 并通过 JSON REST API 请求返回一个短 URL。

它设计为从索引文件工作,可以识别短 URL 并进行重定向或继续访问您的常规网站。可能需要一些 .htaccess 魔法。

我将它与 Alfred(http://www.alfredapp.com/)中的关键词工作流程一起使用,它会将缩短的 URL 复制到剪贴板。

Wash 也可以与 Wash Android 应用 一起使用。

缩短 URL 的点击将创建 Google Analytics 中的页面浏览量。

Wash 可在 Packagist 上找到。

这是我为了自己的使用而构建的,因为我拥有一个超级短的域名,需要一些自托管的解决方案。

/Peter

创建 URL 的 API 调用

POST 负载数据

{
  "token": "TOKEN",
  "url": "http://wa.se"
}

返回结果

http://wa.se/s5f4

错误响应

{
  "status": 0,
  "errorMsg": "Descriptive error message"
}

CURL 示例

curl —X POST -d '{ "token": "TOKEN","url": "http://wa.se" }' http://wa.se/

安装

将以下内容添加到 composer.json 中

"require": {
  "pean/wash": "dev-master",
},

tables.sql 创建表,然后执行以下操作

设置 .htaccess,例如以下内容

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9]+)$ index.php [L]

然后运行一切

$wash = new Pean\Wash(
  array(
    'db' => array (
      'host' => 'localhost',
      'user' => 'root',
      'passw' => '',
      'db' => 'wa',
    ),
    'salt' => '[something salty]',
    'ga' => array (
      'id' => 'UA-12345-6',
      'site' => 'wa.se'
    ),
    'test' => '0',
    'pushbullet' = array(
      'token' => '658a17ac3a4ce4b2e80887347a2caf8a'
    )
  )
);