1

我的一些页面会返回正确的缩短 URL,但有些页面不会。甚至他们在Yourls都被缩短了。我可以在管理面板上看到它。

这是带有缩短 URL 的页面的调试

{"status":"fail","code":"error:url","url":{"keyword":"09266","url":"http:\/\/domain.com\/LilyPad-Arduino-328-Main-Board","title":"LilyPad Arduino 328 Main Board","date":"2015-02-12 00:35:39","ip":"xxx.xxx.xxx","clicks":"0"},"message":"http:\/\/domain.com\/LilyPad-Arduino-328-Main-Board already exists in database","title":"LilyPad Arduino 328 Main Board","shorturl":"http:\/\/doma.in\/09266","statusCode":200,"qrcimg":"http:\/\/doma.in\/user\/plugins\/inline-qrcode\/images\/qrccf6f0d99893974288d48676d9cdbd51a.png","qrimage":"

这是另一个页面的调试,页面上没有 URL,但在管理员处可用

{"status":"fail","code":"error:keyword","message":"Short URL 00027 already exists in database or is reserved","statusCode":200,"qrcimg":"http:\/\/doma.in\/user\/plugins\/inline-qrcode\/images\/qrcd41d8cd98f00b204e9800998ecf8427e.png","qrimage":"

这是我的 PHP 代码

function shortyourls(){
    global $smarty;

    // Inputs
    $shorturl   =   'http://' . $_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI'];
    $signature  =   "123456789";
    $siteurl    =   "http://doma.in";
    $format     =   "json";
    $Artikel    =   $smarty->get_template_vars('Artikel');
    $title      =   http_build_query(array('title' => $Artikel->cName));
    $keyword    =   preg_replace("/[^0-9,.]/", "", ($Artikel->cArtNr));

    // Phases url
    $short = file_get_contents($siteurl.'/yourls-api.php?signature='.$signature.'&action=shorturl&url='.$shorturl.'&format='.$format.'&keyword='.$keyword.'&'.$title);

    $url=json_decode($short,TRUE);
    $output = $url['shorturl'];
    echo $output;
}

知道有什么问题吗?

4

0 回答 0