Embed timeline from user name stored in db


#1

Hello, I have a unique problem to solve for my NPO. My site provide contents for school courses. Each course has its own pages and the instructor needs to display timeline from the course’s twitter account for each course. The course twitter account is saved in database. What will be my choices to solve this issue?

  1. Embed a twitter widget. To my knowledge, that requires a data-widget-id which can only be retrieved from twitter setting. The instructors simply do not want to do that. I can help but it is a maintenance nightmare.

Is there a way to get data-widget-id simply via user name (screen name) via REST API?

  1. Call REST API to get timeline. This route seems to involve a lot of custom code to render the returned data on web page. I’d like to know if it actually is how people handle the dynamic content. I may need to research a little more.

I’m new to twitter integration - any help would be appreciated!
-Sherry


#2

Configure your first user timeline widget from the NPO account. Your NPO Twitter account should appear in the username field.
https://twitter.com/settings/widgets/new/user

Copy-and-paste the generated markup into a new template object to be included by your content management system. Retrieve the username stored for the course to display. Place the username inside a data-screen-name attribute inside the link.

<a class="twitter-timeline"
data-widget-id="1234567890"
href="https://twitter.com/{username}"
data-screen-name="{username}">
Tweets by @{username}
</a>

If no data-screen-name override is provided the widget will display the latest Tweets from your NPO account. All widgets with the same ID will share options for the widget type such as @replies, photo display, or colors.


#3

Sorry I’m not totally clear…Are your suggesting that the same data-widget-id would work for various user names from database? Is the data-widget-id tied to my twitter account? I tried that already yesterday but let me try again.

Maybe I’m just repeating myself, but the user name would be dynamic and retrieved from a database. Each course has its own twitter account. The problem is that I can’t go to widget setting and get the widget id for each account as it is a maintenance burden, not acceptable for my work.


#4

The data-screen-name parameter overrides the username set when configuring your widget. More info:
https://dev.twitter.com/web/embedded-timelines#timeline-selection

The widget ID is associated with a specific Twitter account. If you are creating a widget on behalf of an organization it may make the most sense to create that widget from the organization’s Twitter account, which leaves everything in place if you were no longer with the organization or unable to be reached.


#5