Dynamic Twitter Feed based on URL


#1

Hi,

I have a database with a couple hundred company’s twitter url’s in it. I want to dynamically load the company’s URL into the twitter widget and have that company’s twitter feed populate the widget. Currently the widget is only being populated with the Home Depot feed (because the data-widget-id is from a widget I made for Home Depot).

so my code would look like:

<a class="twitter-timeline" href="{{ company.twitter_url }}" data-widget-id="[id]"></a>

Is this functionality currently supported? Or do I have to generate a separate widget ID for each company?

Thanks!


#2

By Twitter URL you mean for example http://twitter.com/twitterapi?
In that case, you don’t need a different widget id per company. You can use what we call “Timeline Selection” explained there: https://dev.twitter.com/docs/embedded-timelines#timeline-selection
In short you can do something like this:

Tweets by @{{ company.screen_name }}

If you don’t have their screen_name (their account name, for example twitterapi) stored somewhere, you would need to extract it from the URL.


#3

Thanks for the reply. I actually was able to get it working with the following code:

Essentially I used the company’s twitter handle but no href. Is there any reason to include the href if it works without one?


#4

The href and the text inside the is nice to have in case there’s some Javascript problem, or our widgets.js could not be downloaded. Its also what most search engine crawlers are seeing.


#5