有点不缩短服务器机器上的URL

时间:2011-07-27 10:47:53

标签: php url-shortener

我正在使用有趣的API来缩短网址。

这是我正在使用的PHP代码的片段。

<?php
        $bitly = 'http://api.bit.ly/shorten?version='.$version.'&longurl='.urlencode($url).'&login='.$login.'&apikey='.$appkey.'&format='.$format;

        //The above string evaluates to:
http://api.bit.ly/shorten?version=&longurl=http://real.address.replace&login=myname&apikey=A_key_provided_by_bitbly&format=json

        $response = file_get_contents($bitly);

        $json = @json_decode($response,true);
}

当我调用它时,我得到以下JSON响应:

{"errorCode": 500, "errorMessage": "MISSING_ARG_APIKEY", "results": null, "statusCode": ""}

我不能为了我的生活,明白为什么有点回归那个错误 - 特别是因为我传递了api键 - 是什么给出了?

1 个答案:

答案 0 :(得分:1)

参数为apiKey,而不是apikey