开发者

github api returning 1 at the end of json. is this a mistake?

开发者 https://www.devze.com 2023-03-01 03:38 出处:网络
using curl http://github.com/api/v2/json/user/show/username github\'s user api returns this: ...,\"login\":\"myUsername\",\"email\":\"myEmail@test.com\"}}**1**

using curl http://github.com/api/v2/json/user/show/username github's user api returns this:

...,"login":"myUsername","email":"myEmail@test.com"}}**1**

why is there a 1 after the json? Is that a mistake on their part, or is that supposed to be used for something?

<?php

function getGithub($url="user/show/username") {
    $github = curl_init();
    curl_setopt($github, CURLOPT_URL, "http://github.com/api/v2/json/". $开发者_如何学Curl); 
    return curl_exec($github);
}

trying to

echo getGithub();

but since there's the 1 on the end, I have to

echo rtrim(getGithub(), "1");


Set CURLOPT_RETURNTRANSFER. curl_exec() is currently returning true, which you're then echoing, which gets printed as 1.

0

精彩评论

暂无评论...
验证码 换一张
取 消