tell application "Twitter"
properties of item 3 of status of (home timeline of account 1)
end tell
returns
http://i.imgur.com/hKazz.png
tell application "Twitter"
author of item 3 of status of (home timeline of account 1)
end tell
returns
http://i.imgur.com/POk92.png
How can I isolate the “128938832” ?
Sorry for the screenshots.
I don’t have that app, so I can’t test it. In general I would think you want to coerce your result to text and then use standard text manipulation to extract what you want. Sometimes coercing to text can’t be done. It causes an error. And this is possibly your solution because the error message is text. Most times the error message has the information you need… as text.
Here’s an example. Coercing “a” to text causes an error, but you can see that this error message has the information I am trying to get. I just need to parse the error message to extract it. I hope that helps.
try
set a to {a:"a"}
a as text
on error e
return e
end try
I think this is the ‘dirty’ trick hank was talking about.
try
tell application "Twitter" to get author of item 3 of status of (home timeline of account 1)
on error theError
set theAuthor to do shell script "/bin/echo " & quoted form of theError & " | awk -F '\\\"' '{print $2}'"
end try
EDIT: I’m not able to test the code but it’s better that the do shell script is outside an tell application block.
Thanks DJ but
tell application "Twitter" to get author of item 3 of status of (home timeline of account 1)
does not produce an error.
tell application "Twitter" to get author of item 3 of status of (home timeline of account 1) as text
returns
error “sh: -c: line 0: unexpected EOF while looking for matching `‘’
sh: -c: line 1: syntax error: unexpected end of file” number 2
Presumably you’ve tried this and it doesn’t work?
tell application "Twitter" to get id of author of item 3 of status of (home timeline of account 1)
-- Or perhaps some variant with a 'get' intermediate stage, such as:
tell application "Twitter" to get id of (get author of item 3 of status of (home timeline of account 1))
-- Or:
tell application "Twitter" to get id of author of (get item 3 of status of (home timeline of account 1))
Hi Nigel,
Here are the results.
tell application "Twitter" to get id of author of item 3 of status of (home timeline of account 1)
error “Twitter got an error: Can’t get id of author of item 3 of status of home timeline of account 1.” number -1728 from id of author of item 3 of status of home timeline of account 1
tell application "Twitter" to get id of (get author of item 3 of status of (home timeline of account 1))
https://imgur.com/m6SLD
tell application "Twitter" to get id of author of (get item 3 of status of (home timeline of account 1))
https://imgur.com/Gw2yN
SOLUTION: Chris from the AppleScript-Users mailing list just answered my question. The author property has a user id property. user id of author of item 3 of status of (home timeline of account 1) returns “128938832”. :rolleyes: