【问题标题】:Yourls - Post Custom Short Url by ApiYourls - 通过 Api 发布自定义短网址
【发布时间】:2015-02-25 16:15:24
【问题描述】:

我找不到如何将自定义创建的 URL 发送到 Yourls。通常,Yourls 会返回随机生成的 URL,但我想指定特定的 URL 作为响应。

你的通常会回来

http://test.it/8sj39

我想拥有它。我添加了变量 $articlenumber 但不知道如何发送它

http://test.it/test1
http://test.it/doit

我的代码是在动态页面中实现的。缩短将自动生成。

$shorturl = 'http://' . $_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI'];
$signature = "12345678";
$siteurl = "http://test.it";
$articlenumber = $Artikel->cArtNr;

// Phases url
$yourlsinput = "".$siteurl."/yourls-api.php?action=shorturl&url=".$shorturl."&signature=".$signature."" ;

// Open phased url
$fh = fopen($yourlsinput, 'r') or die("can't open file");
//$yourlsoutput = fread($fh,filesize($yourlsinput));
$yourlsoutput = fread($fh,1024);
fclose($fh);

// Converts xml to php array
$xml = simplexml_load_string($yourlsoutput);
$json = json_encode($xml);
$array = json_decode($json,TRUE);

【问题讨论】:

    标签: yourls


    【解决方案1】:

    您缺少keyword,您需要将$articlenumber 作为keyword 参数传递给 curl 以使其生成带有该关键字的链接。

    【讨论】:

      猜你喜欢
      • 2018-02-25
      • 2013-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-31
      • 2020-04-09
      相关资源
      最近更新 更多