2013-03-10 2 views
0

Я хочу приобрести последний твит в AppleScript. Однако переменные «status» не могут сохранить. Как сохранить объект статуса твита?Как получить твит с помощью AppleScript

Он работает:

tell application "Twitter" 
    set tw to text of item 1 of statuses of home timeline of current account 
end tell 

Это не работает:

tell application "Twitter" 
    set tw to item 1 of statuses of home timeline of current account 
    set txt to text of tw 
end tell 
+0

Можете ли вы поделиться код? Невозможно помочь вам без кода ... –

+0

Извините, я фиксировал формат текста вопроса. –

ответ

1

Немного поздновато, чтобы говорить об этом, но взгляните на мое приложение «Twitter Scripter» доступен бесплатно на Mac AppStore.

Это приложение без фасада, предназначенное для доступа к API Twitter от AppleScript тривиально. Он копирует поддержку родного Twitter в OS X (10.8+), и поэтому вам не нужно самостоятельно обрабатывать аутентификацию. Вы можете получать ответы от API twitter в виде структурированных записей AppleScript.

Например:

tell app "Twitter Scripter" 
    set myTwitterAccount to item 1 of (available accounts) as string 
    -- User timeline: This function retrieves the Tweets for a given user name 
    fetch user timeline for username "mousedownsoft" using account myTwitterAccount with excluding replies and including retweets 
end 
1

Там что-то странное с поддержкой AppleScript Twitter.app, но если вам нужно только, чтобы получить несколько свойств, вы можете использовать блок запроса или параллельное назначение.

tell application "Twitter" 
    tell item 1 of statuses of home timeline of current account 
     set t to text 
     set u to url 
     properties 
    end tell 
    -- set {t, u} to {text, url} of item 1 of statuses of home timeline of current account 
end tell 

Или вы могли бы использовать API вместо этого? Это должно работать, если вы запустите sudo gem install twitter и зарегистрируйте заявку на dev.twitter.com.

require 'rubygems' 
require 'twitter' 

Twitter.configure { |config| 
    config.consumer_key = "" 
    config.consumer_secret = "" 
    config.oauth_token = "" 
    config.oauth_token_secret = "" 
} 

p Twitter.home_timeline.first.text 
p Twitter.home_timeline.first.inspect 
+0

Спасибо за очень хороший ответ! –