Skip to content

Instantly share code, notes, and snippets.

@lennartvdd
Last active April 28, 2017 11:49
Show Gist options
  • Save lennartvdd/31f1ccb22a4b931635a9e5dd682a3d10 to your computer and use it in GitHub Desktop.
Save lennartvdd/31f1ccb22a4b931635a9e5dd682a3d10 to your computer and use it in GitHub Desktop.
Asana Api usage example (for beginners)
<?php
//config
$accessToken = "";
$url = "https://app.asana.com/api/1.0/users/me";
//script
$headers = [
"Authorization: Bearer $accessToken",
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode != 200) {
throw new Exception("Invalid request. Code: ". $httpCode. ". Response: " . $response);
}
//result
var_dump(json_decode($response, true));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment