2

I'd like to set the screen_name for a list of tweets using Dukt Twitter.

The screen_name is set in an entry as a plain text field.

{% set entries = craft.entries.section('contactPage') %}
{% for entry in entries %}
{% if entry.twitterHandle|length %}
{% set tweets = craft.twitter.get("statuses/user_timeline.json?screen_name='~ entry.twitterHandle ~'&count=3") %}
    {% if tweets %}
      <h2>Recent Tweets</h2>
      <div class="tweets">
    {% for tweet in tweets %}
        <div class="tweet">
        <div class="text">{{ tweet.text|autoLinkTweet }}</div>
        <div class="date">{{ tweet.created_at|date('M j Y') }}</div>
    {% endfor %}
      </div>
    {% else %}
        <h2>Recent Tweets</h2>
        <p>No recent tweets at this time.</p>
    {% endif %}
{% endif %}
{% endfor %}

Not possible? No matter what I try, I only get the feed for the oauth user. Any help would be greatly appreciated!

Thanks!

1 Answers1

6

Accomplished this by setting the get request url, then passing it into tweets:

{% set handle = entry.twitterHandle %}
{% set url = 'statuses/user_timeline.json?screen_name=' ~ handle ~ '&count=3&exclude_replies=true' %}
{% set tweets = craft.twitter.get(url) %}

Hope this helps someone else. Thx!