[Safari]AppleScriptを使ってTwitterへメッセージを送る(bookmarkletもどき)その2
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
| 固定リンク
「AppleScript」カテゴリの記事
- 濁音 半濁音 置換用レコード(2023.08.21)
- [AppleScript]キーノートの書類サイズを指定して作成(2022.01.09)
- [awk]行頭のスペースを削除する(subで置き換え)(2021.11.16)
- [SpotLight]選択範囲でSpotLight検索(2021.11.03)
- [AppleScript]リソースフォーク(カスタムアイコン)削除(2021.10.12)