How to check tags, releases and download private repos

I am trying to integrate in my application an automatic check for new version/ automatic download/autoupdate.

I am struggling to udnerstand the right http request to send to get this. I already got my token. I tried (using PHP)

$headers = array(
‘Authorization’ => ‘token XXX’,
‘Accept’ => ‘application/vnd.github.v3.raw’
);
$response = Requests::get(‘https://github.com/gbusoni/NS_code/releases’, $headers);

and

$headers = array(
‘Authorization’ => ‘token XXX’,
‘Accept’ => ‘application/vnd.github.v3+json’
);
$response = Requests::get(‘https://github.com/gbusoni/NS_code/releases’, $headers);

but neither of the 2 worked. Anybody knows?

@gbusoni

Welcome to GitHub Community.

There is GitHub Api for releases and tags kinldy have a look into it. Also check your token has permissions for that repo to access the data.

To integrate it in PHP

        $client = new \GuzzleHttp\Client;
        $res = $client->request(
            'GET',
            'https://api.github.com/repos/gbusoni/NS_code/releases',
            [
                'headers' => [
                    'Accept' => 'application/vnd.github.v3+json',
                    'Authorization' => 'token AUTH_TOKEN',
                ]
            ]
        );


        print_r($res->getBody()->getContents());

 
1 Like