Hyperlink Mentions of Users in Stories

为君一笑 提交于 2019-12-11 18:55:28

问题


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);

回答1:


This is (as you keenly observed) really three separate questions (or, well, two), so I'll answer the one that's in the title :-)

So, the answer to your first question is this is a quirk of how we represent links to users in Asana - we actually link to that person's "Assigned to Me" project. Unfortunately, there isn't yet a convenient way to map these in the API, but this is actually something we're working on, we just aren't ready to publish the solution yet, so you'll have to wait on that one I'm afraid.

Additionally, you may want to check out the modified_since in the API docs (you'll find it in the "Querying for tasks" section).



来源:https://stackoverflow.com/questions/22420188/hyperlink-mentions-of-users-in-stories

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!