We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Twitter Extension

Development and Programming

M Swindler's avatar
M Swindler
30 posts
16 years ago
M Swindler's avatar M Swindler

I’ve been wanting to dive into the EE development world for a while now and today I found my inspiration; I wanted to have EE automatically update my Twitter account when I posted weblog entries. A quick search of the EE add-ons section revealed nothing that would do this, so I decided to write my first extension.

I’m happy to report that after only three hours of development, my extension is up and running on my website. I started with the EE Docs and used some code from this tutorial and after only a few missteps I was done.

As I mentioned, the extension is up and running; however I figured I’d post the source code here for anyone to critique. Again, this is my first outing, so I welcome any feedback or suggestions for improvement.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

I’m a pain aren’t I?

I think Leevis LG Twitter extension already does a lot of this doesn’t it?

Nice work though. I think that the EE add-ons section doesn’t get updated all that much nowadays so that’s probably why it wasn’t showing. Either that or the add-ons need to go through testing by the development crew first before they get listed there.

Will definitely check this one out as well though as I have started getting into Twitter these days a lot more.

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Me again, sorry. Just installed the extension to give it a go and was wondering what exactly does it post when you create a weblog entry?

Does it use the title or something else to create the tweet?

Just concerned because if it takes for instance the body of the post then it is only going to use so much and so will get cut off meaning that I will have to think through my titles more carefully 😉

Just wondering what exactly gets posted?

Thanks.

Best wishes,

Mark

       
MeanStudios's avatar
MeanStudios
335 posts
16 years ago
MeanStudios's avatar MeanStudios

Looks simple enough 😊

@Mark - Just had a quick look at the code and it sends the Title of your post along with the url to it. You can change the pretext at the bottom where you set your username/password for twitter.

@M Swindler - I see you are encoding the url to the posts with the Post ID. This might not be the best way to do it for most folks since most people use the {url_title} instead.

Good job though 😊

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen
@Mark - Just had a quick look at the code and it sends the Title of your post along with the url to it. You can change the pretext at the bottom where you set your username/password for twitter.

Yep just did that myself and see that it is sending the title now. Great minds think alike eh? 😊

@M Swindler - I see you are encoding the url to the posts with the Post ID. This might not be the best way to do it for most folks since most people use the {url_title} instead. Good job though 😊

Perhaps the extension could have a setting to change this if needed?

       
MeanStudios's avatar
MeanStudios
335 posts
16 years ago
MeanStudios's avatar MeanStudios
@M Swindler - I see you are encoding the url to the posts with the Post ID. This might not be the best way to do it for most folks since most people use the {url_title} instead. Good job though 😊
Perhaps the extension could have a setting to change this if needed?

Ultimately that’s probably what he should do, ya. Probably would be good practice to move the settings into the control panel along with that option as well 😉. Instead of putting them in the ext file itself. Although I shouldn’t be talking since I haven’t written any ext, plugins, modules myself heh.

       
M Swindler's avatar
M Swindler
30 posts
16 years ago
M Swindler's avatar M Swindler
I think Leevis LG Twitter extension already does a lot of this doesn’t it?

Yeah, I didn’t realize that was there. I was actually VERY surprised there was only one add-on returned with a “Twitter” or “Tweet” search in the EE Add-on section, which is what prompted me to write my own. Is there another EE Add-on repository? If not, how did you find that? A simple web search, perhaps? I’ll check this out at some point and see if there’s any overlap; at first glance it looks like the LG extension is just meant for Twittering from EE - if it doesn’t perform any kind of “simul-casting” (for lack of a better word) I may continue development.

I see you are encoding the url to the posts with the Post ID. This might not be the best way to do it for most folks since most people use the {url_title} instead.

I actually use the URL title on my website for both internal and permalinks; I chose the entry ID because EE recognizes either and the entry ID is more friendly to Twitter’s character limit 😊. Perhaps I’ll put in a switch in the settings…

Thanks for the feedback, guys. I really appreciate it.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Michael,

There isn’t another add-on repository it’s just two things really :

1 - Leevi is well known around here as writing a lot of very good add-ons for ExpressionEngine so that was the first reason and

2 - I pretty much remember every single plugin, extension and module available for ExpressionEngine that’s out there. That comes from having an almost photographic memory and also spending so much time on the forums here 😉

What did you mean by simul-casting by the way?

Best wishes,

Mark

       
M Swindler's avatar
M Swindler
30 posts
16 years ago
M Swindler's avatar M Swindler

Mark,

By simulcasting I meant that I want to Twitter that I posted to my weblog, rather than Twitter directly from EE. The tweet serves to let my followers know when I’ve posted, almost like an RSS feed. I tweet other stuff separately, this just supplements that. Hope that makes sense.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Micheal,

Ah yes I see what you mean now. I do believe however that Leevi’s extension does allow for this too. You can post to Twitter from the bottom of the page or there is also a Twitter tab that appears when Publishing an entry which allows you to send a message that way too. Quite configurable too.

       
MeanStudios's avatar
MeanStudios
335 posts
16 years ago
MeanStudios's avatar MeanStudios
I see you are encoding the url to the posts with the Post ID. This might not be the best way to do it for most folks since most people use the {url_title} instead.
I actually use the URL title on my website for both internal and permalinks; I chose the entry ID because EE recognizes either and the entry ID is more friendly to Twitter’s character limit 😊. Perhaps I’ll put in a switch in the settings… Thanks for the feedback, guys. I really appreciate it.

Actually twitter automatically takes a link and makes it into a tinyurl when submitting a tweet like this. The only reason I say to give the option is so google doesn’t find a second set of URL’s to the posts on your site so there is no duplicate content 😉.

       
DEA's avatar
DEA
257 posts
16 years ago
DEA's avatar DEA

What would be even more exciting is doing it the other way around: by sending a tweet to a particular user account (i.e. @yourblog.com), a post is created.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.