« [Safari]AppleScriptを使ってTwitterへメッセージを送る(bookmarkletもどき) | トップページ | [ResEdit]ResDataBridge »

[Safari]AppleScriptを使ってTwitterへメッセージを送る(bookmarkletもどき)その2

タイトルを取得後
文字列をURLエンコード


Website_image20110425_165751

「SafariTweet2_nokey.scpt.zip」をダウンロード



「SafariTweet2.rtf」をダウンロード

set theTabNo to ""
set theTwitterTitle to ""
set theTwitterURL to ""
set GoogleUrlShortener to ""
set theShorturl to ""
set theBodytext to ""

tell application "Safari"
activate
try
tell document 1
set theTwitterTitle to name
end tell
end try

tell window 1
tell current tab
try
set theTwitterURL to URL
end try

end tell
end tell
end tell

set TheTextToEncode to theTwitterTitle
set theTwitterTitle to my encodeTEXT(TheTextToEncode)

set GoogleUrlShortener to "curl https://www.googleapis.com/urlshortener/v1/url? -H 'Content-Type: application/json' -d '{\"longUrl\": \"" & theTwitterURL & "\"}'" & "| grep 'goo.gl' | awk '{print($2)}' | sed -e \"s/\\\",//\" | sed -e \"s/\\\"//\" " as Unicode text

set theShorturl to do shell script GoogleUrlShortener

set theTwitter to "http://twitter.com/intent/tweet?url=" & theShorturl & "%0ASource:" & theTwitterTitle & "" & "" as Unicode text

set theNewWindowURL to "http://www.goo.gl/" as Unicode text

tell application "Safari"
make new document
tell document 1
tell current tab
open location theTwitter
end tell
end tell
end tell

on encodeTEXT(str)
set scpt to "php -r 'echo urlencode(\"" & str & "\");'"
return do shell script scpt
end encodeTEXT

|

« [Safari]AppleScriptを使ってTwitterへメッセージを送る(bookmarkletもどき) | トップページ | [ResEdit]ResDataBridge »

AppleScript」カテゴリの記事

トラックバック


この記事へのトラックバック一覧です: [Safari]AppleScriptを使ってTwitterへメッセージを送る(bookmarkletもどき)その2:

« [Safari]AppleScriptを使ってTwitterへメッセージを送る(bookmarkletもどき) | トップページ | [ResEdit]ResDataBridge »