githubapi

Php code posted
created at 30 Sep 17:47

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
  $data = 'client_id=' . $_GET['client_id'] .
      '&client_secret=' . $_GET['client_secret'] .
      '&code=' . urlencode($_GET['code']);

  $curl = curl_init("https://github.com/login/oauth/access_token");
  curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

  $response = curl_exec($curl);

  preg_match('/access_token=([0-9a-f]+)/', $response, $out);
  echo $out[1];
  curl_close($curl);
?>
450 Bytes in 2 ms with coderay