请获取“shortUrl”参数 不工作
$json_string = file_get_contents('http://ow.ly/api/1.1/url/shorten?apiKey=APICODE&longUrl=' . urlencode($url));
$json = json_decode($json_string, true);
$shorten=$json['shortUrl'];
答案 0 :(得分:0)
如果你真的看过ow.ly的回复,你会发现它是:
{"results":{"hash":"3hGIhh","longUrl":"http:\/\/www.stackoverflow.com","shortUrl":"http:\/\/ow.ly\/3hGIhh"}}
所以你需要做以下事情:
$shortUrl = $json->results->shortUrl;
或者可能
$shortUrl = $json['results']['shortUrl'];