Training, Open Source Programming Languages

This is page http://www.wellho.net/mouth/2107_How ... -blog.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
How to tweet automatically from a blog

How to Tweet from a Blog

I'm using the MoveableType Blog software for "The Horses's Mouth" ... and I want to tweet my subject line for each new post. But I'm lazy, so I have set it up to happen automatically.

1. I post my blog entry in the usual way

2. I have added the following script at /home/wellho/tweeter/blogtweet on my server:

<php
mysql_connect("127.0.0.1","databaseuser","databasepassword");
mysql_select_db("wellho");
$rs = mysql_query("select entry_id,entry_title from mt_entry order by entry_id desc limit 1");
$hv = mysql_fetch_assoc($rs);
$leid = file_get_contents("blogtweet.txt");
if ($leid == $hv[entry_id]) exit();
`curl --basic --user wellho:twitterpassword --data status="[diary] - $hv[entry_title] - http://www.wellho.net/mouth/$hv[entry_id]_.html" http://twitter.com/statuses/update.xml`;
$fh = fopen("blogtweet.txt","w");
fputs($fh,$hv[entry_id]);
fclose($fh);
?>


See update (at end of this post) w.r.t. this code, which needed update, August 2009

3. I have added a regular timed (crontab) job on the server as follows:

10,25,45,58 * * * * cd /home/wellho/tweeter; /usr/local/bin/php blogtweet > /dev/null

So - about every 15 to 20 minutes - my server checks if a new blog entry has been added. And if it has, it uses curl to submit an update to twitter.

Note:

a) If I submit two blog items very quickly in succession, the first one may not be tweeted.

b) There is a time lapse of up to 20 minutes between me blogging and tweeting.

c) My script isn't 'clever' if I include quotes in my subject line

d) I haven't (in this simple example) checked the blog entry to make sure that it's actually been published.

e) An alternative curl that I tried (and worked) using Json was as follows:
curl -u wellho:twitterpassword -d status="Trying to Autotweet" http://twitter.com/statuses/update.json

Update - 9th August 2009 - The --basic option no longer works - indeed, tweets using it are simply being lost. Remove the option and carry on as before. I suspect that this change relates to the problems that Twitter have had over the last few days.
(written 2009-03-28, updated 2010-06-26)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
H110 - PHP - HTML Web Page Data Handling
  [50] Current cost in your local currency - (2004-09-16)
  [589] Robust PHP user inputs - (2006-02-03)
  [789] Hot answers in PHP - (2006-07-02)
  [896] PHP - good coding practise and sticky radio buttons - (2006-10-17)
  [1001] .pdf files - upload via PHP, store in MySQL, retrieve - (2006-12-19)
  [1053] Sorting people by name in PHP - (2007-01-26)
  [1136] Buffering output - why it is done and issues raised in Tcl, Perl, Python and PHP - (2007-04-06)
  [1169] Emailing as HTML (Web Page) - PHP example - (2007-04-30)
  [1831] Text formating for HTML, with PHP - (2008-10-11)
  [2025] Injection Attack if register_globals in on - PHP - (2009-02-04)
  [2046] Finding variations on a surname - (2009-02-17)
  [2135] What features does this visitors browser support? (PHP) - (2009-04-22)
  [3036] Sending out an email containing HTML from within a PHP page - (2010-11-07)
  [3926] Filtering PHP form inputs - three ways, but which should you use? - (2012-11-18)

G911 - Well House Consultants - Search Engine Optimisation
  [165] Implementing an effective site search engine - (2005-01-01)
  [427] The Melksham train - a button is pushed - (2005-08-28)
  [1015] Search engine placement - long term strategy and success - (2006-12-30)
  [1029] Our search engine placement is dropping. - (2007-01-11)
  [1344] Catching up on indexing our resources - (2007-09-10)
  [1793] Which country does a search engine think you are located in? - (2008-09-11)
  [1969] Search Engines. Getting the right pages seen. - (2009-01-01)
  [1971] Telling Google which country your business trades in - (2009-01-02)
  [1982] Cooking bodies and URLs - (2009-01-08)
  [1984] Site24x7 prowls uninvited - (2009-01-10)
  [2000] 2000th article - Remember the background and basics - (2009-01-18)
  [2019] Baby Caleb and Fortune City in your web logs? - (2009-01-31)
  [2045] Does robots.txt actually work? - (2009-02-16)
  [2065] Static mirroring through HTTrack, wget and others - (2009-03-03)
  [2106] Learning to Twitter / what is Twitter? - (2009-03-28)
  [2137] Reaching the right people with your web site - (2009-04-23)
  [2324] What search terms FAIL to bring visitors to our site, when they should? - (2009-08-05)
  [2330] Update - Automatic feeds to Twitter - (2009-08-09)
  [2428] Diluting History - (2009-09-27)
  [2552] Web site traffic - real users, or just noise? - (2009-12-26)
  [2562] Tuning the web site for sailing on through this year - (2010-01-03)
  [2686] Freedom of Information - consideration for web site designers - (2010-03-20)
  [2748] Monitoring the success and traffic of your web site - (2010-05-01)
  [3670] Reading Google Analytics results, based on the relative populations of countries - (2012-03-24)
  [3746] Google Analytics and the new UK Cookie law - (2012-06-02)
  [4121] Has your Twitter feed stopped working? Switching to their new API - (2013-06-23)


Back to
Learning to Twitter / what is Twitter?
Previous and next
or
Horse's mouth home
Forward to
Funny Amusing, Funny Amazing and The Smarts
Some other Articles
Business Networking for Melksham - 23rd April
MySQL - looking for records in one table that do NOT correspond to records in another table
Why most training fails ...
Funny Amusing, Funny Amazing and The Smarts
How to tweet automatically from a blog
Hire Car, from Atlanta Airport
Ruby Programming and Rails - 4 different courses in one
Ask the Tutor - Open Source forum
What do people think of our Apache httpd / Tomcat course?
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2021: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/2107_How ... -blog.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb