Send a text message from R

前端 未结 2 865
日久生厌
日久生厌 2020-12-16 12:44

I know you can send an email from R with sendMail, and you can tweet with twitteR. Is there any way to send a text message from an R script?

2条回答
  •  自闭症患者
    2020-12-16 12:53

    I always struggled to get my mail configured correctly to send an email from R. But if you are on a Mac and use Mac Messages, you can send a text using Messages with an AppleScript.

    So run the following code in R right in your script:

    send_text = function(message){
        system(paste('osascript -e \'tell application "Messages"\' -e \'send "', message, '" to buddy "555-555-5555" of (service 1 whose service type is iMessage)\' -e \'end tell\''))
    }
    

    Just change the number to the phone number you want to text!

提交回复
热议问题