I'm building a script that will notify a hipchat room about changes on tasks, comments, etc. in Asana.
I'm facing 3 simple problems but I'm stuck and was thinking maybe some of you could help me.
Problem #1: The problem i'm facing is that when someone (a user) get's "mentioned or hyperlinked" in a comment I get a random URL with numbers I can't much to user ID or anything. Maybe there is a logic I'm not seeing?
Same with hyperlinks for tasks and projects? Could you please advice what's the first number of the URL and the second one?
See below the response i'm getting when I get a story from Asana API [8] => Array ( [id] => 10976152589055 [created_at] => 2014-03-15T04:51:40.831Z [created_by] => Array ( [id] => 203288254516 [name] => Juan Martitegui )
[type] => comment
[text] => https://app.asana.com/0/639593560275/639593560275Â testing.
https://app.asana.com/0/241863293563/241863293563Â testing. https://app.asana.com/0/591143197873/591143197873Â testing.
[*] this last 3 URLs are mentions of a USER!
I need that so I in the notification I can actually mention the Users name.
Problem #2: To see which tasks have been updated .. I check the "modification" timestamp and then post all the stories of those tasks to the room in a neat, clear way. The problem is if I create a new task... without modifying it.. that doesn't create a "story" so my "notification" will be empty. Any work around?
Problem #3: Is there a way to search all the modified tasks in a workspace in the last day (regardless of a user) or even better all the modified stories of a workspace in the last day for example?
Let me know please!
Thanks so much.
The code I'm using right now look like this:
$api = 'xxxxxxx'; $api_url = 'https://app.asana.com/api/1.0'; $url = 'https://app.asana.com/api/1.0/tasks/10976287567521/stories'; // workspaces/203178557772/tasks?assignee=203288254516&completed_since=now // tasks/203288254519/stories $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // Don't print the result curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_FAILONERROR, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // Don't verify SSL connection curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // "" "" curl_setopt($curl, CURLOPT_USERPWD, $api); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); // $data = array( // "data" => array( // "workspace" => "203178557772", // "name" => "Task Name", // "notes" => "notes", // "assignee" => "203288254516" // ) // ); // $data = json_encode($data); // curl_setopt($curl, CURLOPT_POST, true); // curl_setopt($curl, CURLOPT_POSTFIELDS, $data); $html = curl_exec($curl); curl_close($curl); $html = json_decode($html, true); echo $url . '
'; print_r($html);