Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Twitter action (Read 11716 times)
Jack Baty
Full Member
*
Offline



Posts: 96

Twitter action
Feb 03rd, 2008, 4:42pm
 
I'm trying a combination of what's posted here  http://www.eastgate.com/Tinderbox/Tutorials/Email.html and Tom Webster's post here http://www.quitecontent.com/2008/02/03.html to post notes to Twitter.

If I use the result of my runCommand() call directly from Terminal it works fine, but from Tinderbox it doesn't.

Here's the Agent's action (without the real passord)...

Code:
Result=runCommand("/usr/bin/curl -d 'status="+$Name+"' -u myusername:mypassword http://twitter.com/statuses/update.atom"); Container="/Archives/Twittered";Text=()
 



This runs, but never makes it to Twitter. Wondering if there's anything I might be forgetting.

Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Twitter action
Reply #1 - Feb 4th, 2008, 11:02am
 
This seems OK to me.  Note that if the note's Name contains quotes, that will foul up the command unless they're escaped.
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Twitter action
Reply #2 - Feb 4th, 2008, 11:31am
 
I don't see an obvious error in the command line quoted but do consider the encoding of strings you pass in to the CL, e.g. encoding things like spaces. v4.0.0+ has some string encoding operators to help with just this sort of scenario. particulatly here look at urlEncode().

I assume "Text=()" is designed to delete the note's body text. A better version might be (within the quotes) "Text=;". The latter has the benefit of both voiding the 'tbx' stub text and re-setting inheritance for $Text. That said I don't think this is the cause of your current output error.

Try:
Code:
Result=runCommand("/usr/bin/curl -d 'status="+urlEncode($Name)+"' -u myusername:mypassword http://twitter.com/statuses/update.atom"); Container="/Archives/Twittered";Text=; 




Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Jack Baty
Full Member
*
Offline



Posts: 96

Re: Twitter action
Reply #3 - Feb 4th, 2008, 1:22pm
 
To follow up, the problem was that each time I tested a tweet from Tinderbox, it included a single quote. I'll try adding urlEncode() to see how the Flickr API deals with it.

Thanks for all of the help.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Twitter action
Reply #4 - Feb 4th, 2008, 1:50pm
 
If MyAttrA is set to "The hut's roof" and with a Rule of:

MyAttrA = urlEncode($MyAttrA);

...we get a value back of "The%20hut%27s%20roof". Also, an inline stray double quote, ", will become %22. so, without being in a position to try the full Twitter test now, it ought to work if you use urlEncode().

Sorry to any Command Line pros for whom the above may be a case of the blindingly obvious!
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Jack Baty
Full Member
*
Offline



Posts: 96

Re: Twitter action
Reply #5 - Feb 4th, 2008, 6:53pm
 
Using urlEncode() worked perfectly, even with quotes in the $Name.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Twitter action
Reply #6 - Feb 5th, 2008, 6:33am
 
You can also read any Twitter user's tweets, assuming you know their username:
  • Create a note
  • Set its AutoFetch attribute to 'true'
  • Set its URL attribute to http://twitter.com/statuses/user_timeline/username.rss where 'username' is an actual Twitter usename. Note: you may need to manually encode any exotic characters like !, #, etc. in the username into %nn formats.
  • Close the note and click #-3 to open the Network dialog. Click "Fetch now".
  • Your note will contain a reverse chronologically ordered list of tweets.

For more on the syntax used above see the Twitter API page.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Twitter action
Reply #7 - Feb 5th, 2008, 6:49am
 
For those still trying to get the sending of tweets working, note that examples here and on the Eastgate example page mention several attributes that occasional TB user may mistake for system attributes but which are in fact user attributes you'll need to add to your TBX to get things working.

Result. This is a user attribute and it will catch any error messages back from runCommand. My experiment show that the Command Line to send tweets doesn't actually return anything (or anything that shows up in Result). However, it is worth using because if you've made a TB syntax mistake in the Rule/Action you use to apply the CL then you will see a message saying there's a parsing error. The latter can help ensure you at least feed a valid TB rule/action into the CL.

Title. This is a user attribute used in the Eastgate example. You might assume it inserts the note's title (like the ^title^ export code). If you do want the note's title, you need to use $Name, which is a system attribute. Otherwise to use $Title you'll need to make a user attribute Title and give it a value for tweet-notes.

The aTbRef page on runCommand() has also been updated to reflect some of these issues.
Back to top
 
« Last Edit: Feb 5th, 2008, 7:50am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
RobertW
Full Member
*
Offline



Posts: 23

Re: Twitter action
Reply #8 - Feb 24th, 2008, 10:04pm
 
After a couple of hours of experimentation, I have posted to Twitter working Tom Webster's method (more or less). I haven't been able to get the method from the Eastgate example page to work at all.

I grasp the basic concept that what goes in Name is the content of the tweet, since tweets don't have titles.

There's a lot more that I need to understand.

1.)Why is Text is mentioned in both the Eastgate action and Tom Webster's action when Text isn't sent to Twitter at all?

2.) Why does Tom Webster's method actually erase anything one might have in Text?

3.) Why does Eastgate's action include the Title attribute, when that isn't sent to Twitter either?

If anyone can shed some light, it might help me figure this out, and be much appreciated.
Back to top
 
« Last Edit: Feb 24th, 2008, 10:05pm by RobertW »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Twitter action
Reply #9 - Feb 25th, 2008, 6:03am
 
#1. The Eastgate example does send the body text of the note; it sends the contents of user attribute Title space+colon+ space and the content of the note's Text. Tom's version just sends the note title (i.e. Name attribute). It's not clear what the Text=() call is trying to do - I suspect the example is cut down from something larger.

The key here is not to be too literal in tearing down the example actions. The bit using TB attribute data is the message and that must not exceed 140 characters and also must be urlEncoded if using other than basic alphanumerics.

For a simplest test possible, I would change this 'status="+$Title+":"+$Text+"' in the Eastgate example to 'status="+$Name+"'. You're now using only a single, system, TB attribute. That said you still need to create a user attribute Result (actually any name you like) that is used as the output for the command line's error - if any. My experiments show that, though not documented, runCommand() used in an action or rule does require to be set as the input to a user attribute**. Anyway, once you're happy getting that to work you can figure out more complex data forms.

#2 As above, I suspect his example is a cut-down of something more complex and/or attribute names have got unintentionally transposed when copying private code to public example (I've done similar before now!). For detail, you'd need to ask Tom - his blog does have a 'Contact' link.

#3 $Title is sent to Twitter, but only if you've remembered to set up a user attribute called Title and to give that a value. The makes more sense than using Name (the note's actual title) to hold the topic/theme as you'd get lots of notes with duplicate names (I assume that's why the Eastgate page uses a Title attribute).

FWIW, I'm working on a (video) tutorial on this topic - I've done the TB stuff, I just need some time to do the video & edit.

What's confusing is if/when a 'result'  attribute is needed. I've suggested elsewhere that Result be a system attribute so it's there ready when needed as it feels like the need for it is an 'internal' thing and something on which the inexpert user could easily trip up.

Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print