最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

腾讯短链接url生成接口_url短网址生成

网站源码admin38浏览0评论

类似于 “http://url/xxxx” 格式的url短网址是用腾讯短链接接口生成的,相较于新浪短链接的广泛应用场景,腾讯短链接更多的是应用于微信中,给大家分享一个腾讯短链接url生成接口,大家试试

腾讯短链接url生成接口:

http://api.monkeyapi?appkey={appkey}&url=www.baidu

API使用说明:

1、在线使用

将API接口地址中 “http://www.baidu”?的部分换成需要缩短的长网址,然后直接复制,前往浏览器中粘贴打开即可生成了。

2、接口调用

如果觉得在线生成的操作比较麻烦,或者需要生成的量比较大的话,也可以直接对接程序调用API自动生成。对接方法可参考下方

PHP调用演示:

$url = “http://api.monkeyapi”;
$params = array(
‘appkey’ =>‘appkey’,//您申请的APPKEY
‘url’ =>‘www.monkeyapi’,//需要查询的网站
);

p a r a m s t r i n g = h t t p b u i l d q u e r y ( paramstring = http_build_query( paramstring=httpbuildquery(params);
c o n t e n t = C u r l ( content = Curl( content=Curl(url, $paramstring);
r e s u l t = j s o n d e c o d e ( result = json_decode( result=jsondecode(content, true);
if(KaTeX parse error: Expected '}', got 'EOF' at end of input: …{ var_dump(result);
}else {
//请求异常
}

/**
* 请求接口返回内容
* @param string $url [请求的URL地址]
* @param string $params [请求的参数]
* @param int i p o s t [ 是 否 采 用 P O S T 形 式 ] ∗ @ r e t u r n s t r i n g ∗ / f u n c t i o n C u r l ( ipost [是否采用POST形式] * @return string */ function Curl( ipost[POST]@returnstring/functionCurl(url, $params = false, $ispost = 0)
{
$httpInfo = array();
$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if ($ispost) {
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    curl_setopt($ch, CURLOPT_URL, $url);
}else {
    if ($params) {
        curl_setopt($ch, CURLOPT_URL, $url.'?'.$params);
    } else {
        curl_setopt($ch, CURLOPT_URL, $url);
    }
}

$response = curl_exec($ch);
    if ($response === FALSE) {
    //echo "cURL Error: " . curl_error($ch);
    return false;
}

$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$httpInfo = array_merge($httpInfo, curl_getinfo($ch));
curl_close($ch);
return $response;

}

常见问题:

1、生成的短链接,为什么原来的参数没有生效?

答:因为长链接中含有特殊字符,需要使用url编码。

2、接口没有返回结果,是什么情况?

答:有些时候接口返回数据有延迟,超时了会生成失败,就无法返回结果了;或者是因为原链接被封了。

3、生成的短链接有效期是多久?有没有访问次数限制?

答:生成的腾讯短链接都是永久有效的,没有访问次数限制,可以放心使用。

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论
ok 不同模板 switch ($forum['model']) { /*case '0': include _include(APP_PATH . 'view/htm/read.htm'); break;*/ default: include _include(theme_load('read', $fid)); break; } } break; case '10': // 主题外链 / thread external link http_location(htmlspecialchars_decode(trim($thread['description']))); break; case '11': // 单页 / single page $attachlist = array(); $imagelist = array(); $thread['filelist'] = array(); $threadlist = NULL; $thread['files'] > 0 and list($attachlist, $imagelist, $thread['filelist']) = well_attach_find_by_tid($tid); $data = data_read_cache($tid); empty($data) and message(-1, lang('data_malformation')); $tidlist = $forum['threads'] ? page_find_by_fid($fid, $page, $pagesize) : NULL; if ($tidlist) { $tidarr = arrlist_values($tidlist, 'tid'); $threadlist = well_thread_find($tidarr, $pagesize); // 按之前tidlist排序 $threadlist = array2_sort_key($threadlist, $tidlist, 'tid'); } $allowpost = forum_access_user($fid, $gid, 'allowpost'); $allowupdate = forum_access_mod($fid, $gid, 'allowupdate'); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); $access = array('allowpost' => $allowpost, 'allowupdate' => $allowupdate, 'allowdelete' => $allowdelete); $header['title'] = $thread['subject']; $header['mobile_link'] = $thread['url']; $header['keywords'] = $thread['keyword'] ? $thread['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>