Caution: You might want to verify that a) the article has a state = 1 (published); b) the publish date is current (not after today) and c) that it is a public message (access = 0),
before sending to twitter.
TASK 1 - URL IN TWITTER
Joomla!'s URL
I talked to Ian about this task and asked him his advice on determining a good Joomla! URL for an article, as it is created.
He suggests continuing to obtain the article ID, as you have indicated with that query.
Then, include the ContentHelperRoute class into your plugin
Code: Select all
require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
And pass that ID you found into the ContentHelperRoute class for JRoute to obtain the URL.
Code: Select all
JRoute::_( ContentHelperRoute::getArticleRoute( $articleid ) )
Getting a good URL is, of course, really important - so - spend a little time verifying this (I will help, as well.)
Sending a URL to Twitter
Next, I recommend using that URL to generate a tiny url.
You really don't want to waste precious space on a parametrized URL Plus, if Twitter is not handling special characters changing amperstands into
& wastes more space...
What about figuring out the tiny url, yourself, and sending it?
Option 1:
Create and lookup tiny url with PHP
Option 2:
Stammy Script: RSS to Twitter using PHP - the article shows how to use CURL to access the tiny url API and create a shortened URL. In this case, it's a cron job and an RSS feed, but you can easily adapt it your purposes to build a tiny url in realtime. The gmail authentication plugin (plugins/authentication/gmail.php) uses CURL. So, between those two resources, you should be able to get a tiny url to pass on to Twitter.
Sending the URL *is* worthwhile. Driving clicks back to the website is the big benefit to hooking a website up to a SN, like Twitter.
TASK 2 - JOOMLA! USER
If you really want to do this, it would be HUGELY powerful in a multi-user blogging environment. Kevin Devine has a
UserMeta System Plugin that is drop dead easy to use. You could suggest people use his plugin - or another method of extending JUser parameters - to add a TwitterURL parameter. Then, users could specify their Twitter URL in their profile.
Your plugin would could add a parameter indicating whether or not these extended user parameters will be used. If the parameter is set to Yes, your code would lookup the TwitterURL for the article author and send the title to that location, instead of the default Plugin location.
This would be HUGE. Consider it please.
TASK 3 - JOOMLA! SECTIONS AND CATEGORIES
Just add a category and section text box that would limit tweets to those selections (comma separated list). There are many examples of this in the core. Menu items - modules, etc.
Twitter Fan Site
Might want to add
your JED link to
Twitter Fan Wiki
HTH,
Amy
Edit - while I was researching - I see you made some changes to your post. So, I'll wait for you to consider some of this and respond to your next post.