Jump to content
ryan

Twitter Feed (MarkupTwitterFeed)

Recommended Posts

There was a request that I add an official thread for this module, so here it is. MarkupTwitterFeed generates a feed of your tweets that you can output on your site. When you view the processwire.com homepage and see the latest tweets in the footer, this module is where they are coming from. This module was recently updated to support Twitter's new API which requires oAuth authentication. 

  • Like 4

Share this post


Link to post
Share on other sites

Thanks ryan - used this at the weekend to replace a home-brewed bit of code I was using that didn't work after the Twitter API 1.1 update.

The markup options were especially handy as it meant I didn't have to change my template code much at all :)

  • Like 1

Share this post


Link to post
Share on other sites

Updated version to 2.0.1 which adds a 'relative' option for the date/time stamp setting. That makes it display the time as strings like "5 minutes ago", etc. The other change is that the module can now be iterated with a foreach(), useful for people that want to handle all of their own markup generation. If you take this approach, be sure to read the example and notes in the readme file. 

  • Like 1

Share this post


Link to post
Share on other sites

Great module, when you have time please fix the link to twitter dev on the module page  ;)

  • Like 1

Share this post


Link to post
Share on other sites

Just installed this module. But I can't figure out what the "Access Secret" is in the modules configuration settings.

Where can I find it ? I can't find it at dev.twitter.com

Thanks.

Share this post


Link to post
Share on other sites

You have, al other stuff is listed there. But not the "Access Secret".

Thanks. ( reading is difficult sorry )

  • Like 1

Share this post


Link to post
Share on other sites

I get an error with this info in error-log: {"errors":[{"message":"Bad Authentication data","code":215}]}

I have checked the authentication data many times, but don't know how to further debug this. Could someone help?

EDIT: Is this module supposed to work when my site is not yet on public IP? Can Twitter authentication work when PW is on localhost in home network?

Share this post


Link to post
Share on other sites

@lpa: I'm seeing this issue too, can't quite figure out what's causing it yet though. Twitter authentication should work from localhost, at least as long as callbacks etc. are set properly (quite a few topics about this if you try Googling).

Twitter's oAuth test (cURL) is working from localhost, but the module doesn't. I'd check if code samples in tmhOAuthExamples work either, but don't really have the time right now.

Share this post


Link to post
Share on other sites

could this possibly be an error on line 157 (note - already posted an issue on github)?

     @ @param array $options



			
		
  • Like 1

Share this post


Link to post
Share on other sites

@lpa: I'm seeing this issue too, can't quite figure out what's causing it yet though. Twitter authentication should work from localhost, at least as long as callbacks etc. are set properly (quite a few topics about this if you try Googling).

Twitter's oAuth test (cURL) is working from localhost, but the module doesn't. I'd check if code samples in tmhOAuthExamples work either, but don't really have the time right now.

The same here. Get the module not to work. The feed is loaded and cached, then crashes the Apache (WAMP environment, PHP 5.3.8 + Apache 2.2.22). In the error log (PHP, PW or Apache) there is no entry. Very kurrios. On the production server I have not tried it yet.

Share this post


Link to post
Share on other sites

Hello,

is there a possibility to put the url from a tweet into a real link?

$t->linkUrls = true; as an option doesn´t work unfortunately.

Share this post


Link to post
Share on other sites

at first: thank you Ryan for PW and all the great things around.

I'm using the MarkupTwitterFeed Modul and it works fine. Now I'm looking for a way to filter the tweets for a hashtag - to show only these.

Share this post


Link to post
Share on other sites

Hi makari,

I was lloking for the exact same thing some time ago. I wrote a pull request to add this functionality, you can check it out here: https://github.com/ryancramerdesign/MarkupTwitterFeed/pull/3

Unfortunately, the best solution I could come up with was fetching all tweets and then filter them. If you know a way to do this right from the twitter API, I would be glad to here about it.

Share this post


Link to post
Share on other sites

Hi Philipp,

thank you for your answer. It sounds very good. In the next few days I will try your solution.

Share this post


Link to post
Share on other sites

it works great! Thank you again, Philipp

I'm not a programmer but I think your solution ist as good as possible because the hashtags are part of the tweet text.

Share this post


Link to post
Share on other sites

Hello,

is there a possibility to put the url from a tweet into a real link?

$t->linkUrls = true; as an option doesn´t work unfortunately.

Doesn't work here either.

Also @ Mentions and # Hashtags.

This is what it looks like:

0cJXa2u.png

These are my options set:

<?php

    $t = $modules->get('MarkupTwitterFeed');
    $t->limit = 20;
    $t->linkUrls = true;
    $t->showHashTags = true;
    $t->showAtTags = true;
    $t->showDate = 'after';
    // generated markup options:
    $t->listOpen = "";
    $t->listClose = "";
    $t->listItemOpen = '<div class="feed">';
    $t->listItemClose = "</div>";
    $t->listItemDateOpen = "<span class='date'>";
    $t->listItemDateClose = "</span>";
    echo $t->render();
?>

Hope you guys can help me out.

But I think the structure of twitterJSON changed, so that might be a reason.

Share this post


Link to post
Share on other sites

Hi Misan,

are you talking about turning Mentions, Hashtags and URLs inside the tweet into links? If that's the case, that should be easy to implement. I guess I did this for a project some time ago. I'll have a look into the code when I'm home, maybe that's what you are looking for :-)

Share this post


Link to post
Share on other sites

Hi Misan,

are you talking about turning Mentions, Hashtags and URLs inside the tweet into links? If that's the case, that should be easy to implement. I guess I did this for a project some time ago. I'll have a look into the code when I'm home, maybe that's what you are looking for :-)

Hi there!

Yep, I would like to have @ at-tags linked to the said twitter profile.

I thought thats possible with the default twitter module?

Thanks in advance!

Share this post


Link to post
Share on other sites

how to call image twitter use module Markup Twitter Feed ?? please help me 

If your question, it is about how to display images in tweets, the default module markup does not handle images.

But that is not hard to do: you have to use a foreach loop to iterate over the tweets and create your own markup inside the loop, like in the example in the  readme.

$t = $modules->get('MarkupTwitterFeed');
$t->limit = 3; 
foreach($t as $item) {
  echo "<p>$item[text]<br /><span class='date'>$item[created_at]</span></p>";
}

For the internal structure of twitter media, you can have a look at https://dev.twitter.com/overview/api/entities-in-twitter-objects

  • Like 1

Share this post


Link to post
Share on other sites

About handling the display of images from a twitter feed, I did this today by adding code inside MarkupTwitterFeed.module. I post it here in case it could help other pw users having the same needs.

// To be added in public function renderItem, before: $out = $options['listItemOpen']; 

	if (isset($item['entities']['media'])) {
	    $mediaUrlField = wire('config')->https ? 'media_url_https' : 'media_url';
	    
	    foreach($item['entities']['media'] as $m) {
		if($options['listItemPhoto']) {
		    $photoHtml = str_replace(array('{src}', '{title}'), 
					     array(wire('sanitizer')->entities($m[$mediaUrlField]), 
                                                   wire('sanitizer')->entities($m['display_url'])), 
					     $options['listItemPhoto']); 
		    $text = preg_replace('!' . preg_quote($m['url'], '!') . '(\b|$)!i', $photoHtml, $text); 
		} else {
		    // Hide the media reference in the text
		    $text = preg_replace('!' . preg_quote($m['url'], '!') . '(\b|$)!i', '', $text); 
		}	
	    }
	}

where $options['listItemPhoto'] contains the html for a Twitter photo. For example, if you simply want to display the image, you can set it to:

$options['listItemPhoto'] = "<img src='{src}' title='{title}'>";

This will be rendered like in this screenshot:

post-2086-0-30680600-1425905381_thumb.pn

  • Like 4

Share this post


Link to post
Share on other sites

Doesn't work here either.

Also @ Mentions and # Hashtags.

Can anybody help me to get the hashtags and mentions to work?

They're shown, but not 'linked' as mentioned before.

Any help would be appreciated!

Share this post


Link to post
Share on other sites

No links for me either in Tweets. I will post the issue to Git.

Share this post


Link to post
Share on other sites

Had some time to look at the module and it looks like links were not in the original plan. Would require some editing of the module to allow links, especially as entities are converted. Will look at this when i have some time.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: PrivacyWire Git Repo
      Download as .zip
      I would love to hear your feedback 🙂
      CHANGELOG
      0.1.1 Debugging: fixed error during uninstall 0.1.0 Added new detection of async scripts for W3C Validation 0.0.6 CSS-Debugging for hiding unused buttons, added ProCache support for the JavaScript tag 0.0.5 Multi-language support included completely (also in TextFormatter). Added possibility to async load other assets (e.g. <img type="optin" data-category="marketing" data-src="https://via.placeholder.com/300x300">) 0.0.4 Added possibility to add an imprint link to the banner 0.0.3 Multi-language support for module config (still in development) 0.0.2 First release 0.0.1 Early development
    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      Since 0.0.4, instructions and changelog can be found in the README only. You can find it here  🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
×
×
  • Create New...