API Stuff / 短连接API
We actually have an API for the LiURL site, although I haven’t really documented it that well as of yet. As we’re a brand new site, we’re busy building in functionality, so this will get expanded in further posts as we add features.
To get a Shortened URL (aka Little URL) , the call is this:
http://liurl.cn/api-create.php?url=
Which returns the short URL. If you’ve been naughty and haven’t passed a valid URL, then it will return you a big fat -1 for your efforts.
Strangely enough, we also have the diametrically opposite call of that, which (suprise suprise) gives you a long URL from a shortened one
http://liurl.cn/api-create.php?tinyurl=
This also returns a -1 failure if the URL isn’t one we know about.
Some sample PHP code after the break
虽然我目前仍未正式书面记录,不过在LiURL网站 我们已经使用了API。由于我们是新建的品牌网站,目前我们正忙于建设网站的功能性。所以这部分我们将在以后增加网站新特性时候加以扩充。
如果需要缩短后的链接 如下所示
http://liurl.cn/api-create.php?url=
它将返回缩短后的链接。如果您没有通过正规的链接那么将会出现大大的 -1错误提示。
奇怪的是,我们也遇到了完全相反的情况,有时它会从短链接提供一个长链接(非常奇怪)。
http://liurl.cn/api-create.php?tinyurl=
如果链接不正确 它同样也会出现 -1 错误提示。
以下是一些错误后的PHP编码样本。