Twitter get n-number of timeline from each user (loop)


I am currently trying to get timelines/tweets of our business’ followers. I want to limit the timelines to only 5 or 10 tweets per user. For that, I created a twitter get follower workflow and have the followers as a variable to loop the timelines. However I cannot seem to get it to work using the variables.

My workflow is as following:

When I use the usernames as loop variable, it stuck at the first row, and error on the second row.
How do I resolve this?
The sample workflow (with masked API and company twitter username) is also attached. Thanks!
Twitter (20.7 KB)

Hi @Mizunashi92

I just tested your nice little workflow and it is successfully receiving the last 5 tweets for every follower, I am not getting an error. What is the error you get on the second row?

Hi Oole,
Thank you very much for the reply.
I always get this error:
Execute failed: 401:Authentication credentials ( were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync.
{“request”:"/1.1/statuses/user_timeline.json",“error”:“Not authorized.”}

This only happens when I loop through them…
It does not always second, but after some loop, it can happen.

Is it about the limit?

I added partition before taking column to variables. So I took 4 random users, getting 5 tweets for each user.
Sometimes it works, sometimes it return the above error.

Any idea why this happens?


So I managed to run in to the problem as well. The error returned by Twitter does not give too much information about the root of the issue, but I think I figured out why it happens. Some user may have set their account’s Tweets to protected. In that case you can only retrieve the account’s tweets if:

  • You use that user’s credentials to login .
  • The credentials you use belong to an account following the user.

That’s why the node fails. I guess it would be simplest to just skip that user in the loop in that case. I modified the workflow accordingly. See twitter_retrieval.knwf (31.2 KB)

Edit: typo

Hi Oole,

Thanks for the reply and the help…
I checked the catch error node and I saw that it is recording the errors.

However, I was then met with another error.
Execute failed: Input table’s structure differs from reference (first iteration) table: different column counts 1 vs. 27

Can you explain me what is this error?

Thank you so much!
Best regards,

The problem is probably that the first iteration does fail in your example, so that in the first iteration you have an empty table instead of the 27 columns of information which you would expect from the Twitter Timeline node.

A simple fix would be to prepend a row to the table (after the second column filter node) with a user name, of which you know that you will be able to retrieve the information. I cannot investigate further right now because i run into the rate limit :roll_eyes:

Happy to help!

1 Like

Hi Oole, sorry for taking some time to reply.

I have tried to prepend the table by adding a username which I 100% sure will work (which is mine).
It ran through the lists, but after several iterations, it is still showing the same error message.
It is a bit strange considering that the try and catch error should have separated the working and non working variables.

I agree, it’s a little weird.

I did not manage to reproduce it on the list of twitter handles I’m testing on. I run in to the rate limit before anything else happens.

Did you take a look at the table which fails to be appended to the rest of the loops output. That would be the table that supposedly only has one column.
It seems like twitter is returning something on the user, but it’s not the full set of selected fields. Depending on what the table looks like, it might make sense to enhance the loop or try-catch block, so that tables or rows that do not have the full field set are simply ignored.

Thanks oole,
Any example workflow available on this try/catch block enhancement that you mentioned earlier so that I can study and improve my workflow?

Thanks in advance!
Best regards,
MizuTwitter (51.4 KB)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.