Question

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/". $url); 
    return curl_exec($github);
}

trying to

echo getGithub();

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

echo rtrim(getGithub(), "1");
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top