0

我的页面上已经有一个从 curl 生成 url 的函数。我需要使用以下字符串以文本格式或使用 shortswitch.com api 的“简单”返回短 url。

这是我的代码:

<?php
$long_url = urlencode('curPageURL()');
$url = "http://api.shortswitch.com/shorten?apiKey=[apikey]&format=simple&longUrl={$long_url}";
$result = file_get_contents($url);
print_r($result);
?>

我正在尝试使用我为 bit.ly 找到的功能与 shortswitch.com api 一起使用作为 shortswitch.com/admin/api。

我的问题是我没有从函数中获得任何类型的输出,也没有生成缩短的 url。

最好的祝福,

4

1 回答 1

1

我只是猜测您实际上是在尝试调用该函数curPageURL()对其结果进行 url 编码,而不是对字符串“curPageURL()”进行 url 编码:

$long_url = urlencode(curPageURL());
于 2012-05-09T01:26:50.847 回答