Last active
April 28, 2017 11:49
-
-
Save lennartvdd/31f1ccb22a4b931635a9e5dd682a3d10 to your computer and use it in GitHub Desktop.
Asana Api usage example (for beginners)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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