Asana: convert user #-tag to API object - asana

I'm parsing the description of tasks for user links (#-tags) that we use to identify different roles on an item. I noticed something weird about the IDs though.
In the notes of a task returned from the API the #-tags are converted to links in the form https://app.asana.com/0/<int_id>/<int_id> which, when visited in the browser, show the user's tasks but when I use that ID to query the API as in https://app.asana.com/api/1.0/users/<int_id> I get a 403 with this response: {"errors":[{"message":"user: Not the correct type"}]} - further investigation showed that the IDs used in the #-tags are different from those used in the API for the same user, even though they both lead to the same page.
My question is are these IDs meant to be opaque or is there a way to convert them to the correct corresponding API IDs (short of browser scraping)?

Unfortunately, it's not possible at this time. In comments and notes (basically, anywhere in Asana that Rich Text is possible), we represent users as the URI to their "My Tasks" page, which is different from their User ID (as you noticed).
We are exploring ways to close this gap, but don't have anything to share at this time. I know that's not super helpful, but I hope it at least helps to have a definitive answer :-(

Related

SurveyMonkey API v3 GET Responses fields

In my app I used the get_respondent_list API in API v2 to get an overview of the responses and to allow me to select those responses which were relevant to download in greater detail - fields of interest to me included date_modified, status .
I had hoped that /surveys/{ID}/responses would give a similar facility but all it returns for each response is href and id. The parameters of the call enable me to filter the list in various ways but I would need to make several calls to identify the different categories that I am interested in.
When I made a similar point about the survey list it turned out there was an incorrectly documented include parameter which I could use to get additional fields in the response. I tried that for /surveys/{id}/responses but that was rejected. Could such a facility be added?
If not I guess I will go for /surveys/{id}/responses/bulk and do all the work in the app.
The bulk endpoint is the correct choice. It is basically a call to /surveys/{ID}/responses with 'include' covering every field. The only downside is is the smaller maximum page size. Not sure sure what additional work you are referring to, since you would need to handle pagination at /surveys/{ID}/responses for more than 1000 responses, and all the fields you are looking for are available at the top level of the returned response dictionary.
This wrapper for the API (not written by me) makes it fairly easy to get all the responses from a survey paired with the relevant question details.
In order to get the data structured in a way that resembles the output from the manual export, a bit of gymnastics is needed (I can recommend Pandas' .pivot_table(). Which columns that contain the actual answers vary depending on questions type, adding further complications depending on the complexity of the survey.

Displaying tweets from multiple users (similar to Embedded Timelines) without twitter-side user lists

I am new to Twitter and need some tips.
I need to display tweet feed from multiple users on some webpage.
The first thing I stumbled upon is Embedded Timelines. It allows to display tweets from list of users but the gotcha is that those lists should be maintained on Twitter-side (i.e. I cannot specify #qwe and #asd only on my side and get timeline without adding those users into list on Twitter-side).
The thing is that list of users that should be included into timeline is dynamic and managing those lists through Twitter API will probably be painful. Not to mention that my website will probably generate tons of those lists and I feel that I will violate some api quotas sooner or later.
So, my question is - am I stuck with using Embedded Timelines that refer some user list on Twitter-side and managing those lists through, say Twitter REST api, or there is a simplier way to do what I want?
It's pretty simple to display tweets for multiple users.
Links to start with
This post explains some of the search queries you can make
This post is a simple library to make requests to the twitter API that 'just works'
Your Query
Okay, so you want multiple users. The endpoint you're looking at using is the search/tweets one: https://api.twitter.com/1.1/search/tweets.json.
The query string uses :from and you can interpolate multiple froms with AND/OR.
An example query for the GET request:
?q=from:user1+OR+from:user2
Read more about the search API queries here.
Your "over-the-quote" issue
This is something you're going to need to figure out yourself - depending on the number of requests you expect to make, and the twitter imposed limits, maybe some sort of caching or saving information when you hit your limit, and only pull back from the cache whilst you're hitting your limit..

Is there a way to get a list of users based on a hashtag they used?

I want to get a list of users who have used a particular hashtag. Eg. #ManOfSteel.
How can I get a list of the users who are using that hashtag as well as their details (like which city they are tweeting from) using a twitter API or any other means?
Yes, you can. And it's quite simple, really.
According to the documentation:
GET search/tweets: - Returns a collection of relevant Tweets matching a specified query.
Resource URL: https://api.twitter.com/1.1/search/tweets.json
Now if you scroll down on that page, it gives an example of what a query for a tweet returns (I took a screen, sorry about the appalling arrow, it's 10am here and I haven't had my tea yet).
Great! So you know the URL and method (GET) that you need to get your data. As for searching for a hashtag specifically, the query documentation is what you're after.
This is basically as urlencoded string in the GET request like: ?q=#hashtag. Perform the search like that and you'll get back the data above. Then just loop through it, find the user object, and grab the value location key if you want the user's city.
Now, as for a library to interact with the twitter API, you haven't even stated what language you're using. From your profile, you use JAVA I'm guessing. Regardless, checkout the libraries page on the twitter dev site - there's one for JAVA that looks pretty good (and many for other languages too).
If you were using php, this post would be immensely helpful.

Find the number of times a tweet has been viewed

There have been quite a few number of start-up pertaining to analyzing Twitter data. There is CrowdBooster, then there is Klout, which use Twitter data to tell the user their True reach.
I have got the following two questions:
1) Is there a way to find out who has viewed one's tweet, or the number of people that have viewed a tweet. Crowdbooster claims to tell you how many impression one received per tweet. How do they do it?
2) Thousands and thousands of links are shared each day on Twitter. Can we find out which user has clicked the link in a tweet?
I have looked through Twitter API and some of the companies that have licensed Twitter's Firehose, but have not found anything that meet my needs.
Also, to give you a short answer to your 2nd question. Now that we've established that view analysis is impossible. Can you find out which user has clicked on that link, absolutely. And depending on what your talking about, user as far as the user who has clicked on the link or the user that has the link on their Twitter stream. Both are possible,
in the case of A, you would get the referring users IP address. Methods vary depending on language.
But what I think your asking for is scenario B, finding out which user has the link in their Twitter stream. This can be done by querying the link, the API response you will get can include tweet entities which will list all this information out for you and more. Open up a firehose with your link and watch what comes in.
https://dev.twitter.com/docs/streaming-api/methods
1) Is there a way to find out who has viewed one's tweet, or the
number of people that have viewed a tweet. Crowdbooster claims to tell
you how many impression one received per tweet. How do they do it?
No, in the case of a view - this would be impossible. The tweet impression can happen in multiple silos. On the website, in a widget, in a mobile app. You can imagine that it's simply not possible to get the impression of a tweet on a view because of this reason and because unlike a click, there is no I viewed this tweet identifier sent when a view has been enacted. I spent a great deal of time researching for a way to get the tweet impression even based on a similar clicked link and this is not even possible. (edit: it's possible see the last paragraph) This brings us to question 2.
2) Thousands and thousands of links are shared each day on Twitter.
Can we find out which user has clicked the link in a tweet?
Yes, what these websites are mainly doing is analyzing links that you process through their website. If you can have a unique hash marker on a link then analysis becomes possible. Without a unique hash marker, Twitter will re-interrupt two of the same links in a exactly the same way, even in the case that it shortens your link to it's custom t.co wrapper.
This means the only reliable way to do tweet analysis is by including a unique link marker code on your tweet and analyze the the fact that somebody that has hit your server has clicked on that link.
There is a somewhat hidden Twitter API feature that helps you understand how popular a particular link is. That being the link count API .. http://urls.api.twitter.com/1/urls/count.json?url=
Something really outside of the box you can do if your set on analyzing multiple versions of exactly the same link without using markers and if your also using the Streaming (firehose) would be to analyze the tweet views (using the link count API) on similar links that hit your server. The link that got the +1 boost in view is the one that hit your server. But that's about the extent of creative analysis you can get with your tweets and more specifically the links, as mentioned links are the only thing your really able to analyze when it comes to Twitter.
1) Is there a way to find out who has viewed one's tweet, or the number of people that have viewed a tweet. Crowdbooster claims to tell you how many impression one received per tweet. How do they do it?
Yes, sign up for Twitter Analytics https://analytics.twitter.com (free service provided by Twitter) and you can see how many people view (impressions) for each tweet and totals for specific dates or a date range.
2) Thousands and thousands of links are shared each day on Twitter. Can we find out which user has clicked the link in a tweet?
Yes, you can do this. Using a URL shortening service like Bitly.com you can track how many clicks you had from Twitter (only give out that Bitly link on Twitter to do this). But if you want more indept information you may need to create a tracking software, as I don't know of any available. To do that you would need the tracking software to track the link and find out the refer header and see if it's from Twitter (or better yet, just give out a unique URL for your tweets), then you would need to use the Twitter API to find out the handle (username) of that visitor who clicked your link. Lastly store this information in a database so you can review who clicked what link.

How to get a list of all retweeters in Twitter?

I have seen numerous companies doing like Twitter lotteries where users got to retweet their tweet and then one of retweeters will get the prize or whatever.
I was wondering now how do they get the list of all retweeters or pick the winner?
I checked Twitter API and found only this thing: GET statuses/retweets/:id but it returns maximum of 100 retweeters. Is that the only way?
It looks likes there's a couple services out there doing almost exactly this. A quick google pulls up http://onekontest.com/ and there's a few other Twitter contest services, but they all seem to be different levels of broken since they haven't kept up with changes to the API.
As far as the Twitter API itself is concerned, if you were expecting more than 100 responses, I think using GET statuses/mentions makes the most sense. That API call returns any mentions of a user, and you can pass the flag include_rts to include any retweets of your tweets. Then, if you wanted to list RTs of a specific tweet, you could check the in_reply_to_status_id field in the returned data to see if it matches the original tweet ID. This API call only returns the last 800 status, 200 at a time, so if you expect a bunch of data, you would need to poll the API repeatedly over time to get all the tweets. I imagine services like favstar are doing exactly this, just on a larger scale.
If you're actually looking for code to do something like this, I wrote a sinatra app called twitter-rss-digest which handles querying Twitter over time to track different sorts of queries. It's pretty rough, and doesn't quite handle this specifically, but it might point you in the right direction if you want to code something.
The Twitter API has an endpoint that returns up to 100 retweeter IDs for a given tweet.
Note that for historical reasons, that endpoint only returns up to 100 results and the documentation about the cursor is useless. Twitter refused to fix the situation.
2013 note
That said, the first thread on the Developers site that surfaced in a quick google has #episod, a Twitter employee saying:
You can't likely get to all of them. The data is spread out. Your best bet is to use the REST API to determine many of the users who performed the retweet, but the data will still be constrained.
It's easiest to track retweets as they happen rather than try to find them from the past. Use the Streaming API for that.
I like muffinista's method, but I think if you want a 100% complete list of retweets, simply enable the retweet email notifications and write a script that polls the email box for those matching the subject "retweeted one of your Tweets!" and put the data into a table. Do this right from the start.
The site https://twren.ch/ enlists all the retweeters for a given tweet (note that it only enlists retweeters who are direct followers of the source tweeter.) Nevertheless its probably the only public source available.

Resources