Help! Who can transfer code or related links for long and short websites ~~

Source: Internet
Author: User
Help! Who can transfer code or related links for long and short websites ~~ Mutual transfer of long and short websites

Could you please give me a code or related link for mutual transfer of long and short websites?
Written in php
Do not use databases
Similar to function encryption
Thank you! ^


Reply to discussion (solution)

Great Gods help me ~~~~~

Go to the interfaces of google or Baidu

Go to the interfaces of google or Baidu

All of these interfaces are skipped and then jumped back. what I want is mutual conversion like function encryption.

Short URL, which is controlled by others, you can use the API long URL for query.
For example, bitly.com
It's API documentation in http://dev.bitly.com/links.html

Short URL, which is controlled by others, you can use the API long URL for query.
For example, bitly.com
It's API documentation in http://dev.bitly.com/links.html
I felt slow when I used Baidu APIs for batch Conversion. Is it wrong?

function dwz($url){$ch=curl_init();curl_setopt($ch,CURLOPT_URL,"http://dwz.cn/create.php");curl_setopt($ch,CURLOPT_POST,true);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);$data=array('url'=>$url);curl_setopt($ch,CURLOPT_POSTFIELDS,$data);$strRes=curl_exec($ch);curl_close($ch);$arrResponse=json_decode($strRes,true);if($arrResponse['status']==0){echo iconv('UTF-8','GBK',$arrResponse['err_msg'])."\n";}return $arrResponse['tinyurl'];}for($i=1;$i<=10;$i++){echo "http://zhidao.baidu.com/question/".rand(0,100000)."$i.html----->".url_short("http://zhidao.baidu.com/question/".rand(0,100000)."$i.html")."
";}

Thank you for your help ~~~

The code you wrote above has a problem, and we don't see where dwz is used.

Mutual transfer of long and short URLs
Long to short, short to long is not reversible
I don't think it is a one-to-one ing. it cannot be implemented without third-party storage mappings.

Mutual transfer of long and short URLs
Long to short, short to long is not reversible
I don't think it is a one-to-one ing. it cannot be implemented without third-party storage mappings.

Third-party storage is not required, unless you apply for a domain name, and then perform a database comparison, a column of Long addresses, and a column of short addresses. you need to query the database when necessary, however, almost all domain names with a short URL cannot be applied for now.

The code you wrote above has a problem, and we don't see where dwz is used.

Sorry, I am stuck wrong.

Function dwz ($ url) {$ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, "http://dwz.cn/create.php"); curl_setopt ($ ch, CURLOPT_POST, true ); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true); $ data = array ('URL' => $ url); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data ); $ strRes = curl_exec ($ ch); curl_close ($ ch); $ arrResponse = json_decode ($ strRes, true); if ($ arrResponse ['status'] = 0) {/** error handling */echo iconv ('utf-8', 'gbk', $ arrResponse ['err _ msg ']). "\ n";} return $ arrResponse ['tinyurl'];} for ($ I = 1; $ I <= 10; $ I ++) {echo "http://zhidao.baidu.com/question ". rand (0,100000 ). "polici.html -----> ". dwz ("http://zhidao.baidu.com/question ". rand (0,100000 ). "ii.html ")."
";}

Mutual transfer of long and short URLs
Long to short, short to long is not reversible
I don't think it is a one-to-one ing. it cannot be implemented without third-party storage mappings.

Can I use other methods besides databases?


Mutual transfer of long and short URLs
Long to short, short to long is not reversible
I don't think it is a one-to-one ing. it cannot be implemented without third-party storage mappings.

Third-party storage is not required, unless you apply for a domain name, and then perform a database comparison, a column of Long addresses, and a column of short addresses. you need to query the database when necessary, however, almost all domain names with a short URL cannot be applied for now.

Currently, it is implemented using the database method. I want to know if there are other methods for implementation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.