Skip to content

Instantly share code, notes, and snippets.

@itayher
Created October 26, 2016 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itayher/4c93ef4cf5b7040a5ef8b38749fa3aad to your computer and use it in GitHub Desktop.
Save itayher/4c93ef4cf5b7040a5ef8b38749fa3aad to your computer and use it in GitHub Desktop.

Get Access Token

PHP cURL

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.backand.co/token",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "grant_type=password&appName=todoswithuser1&accessToken=45f33798-22c4-46c2-aa35-bc28c854322a",
  CURLOPT_HTTPHEADER => array(
    "accept: Accept:application/json",
    "cache-control: no-cache",
    "content-type: application/x-www-form-urlencoded"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment