Apollo
Apollo

Reputation: 9064

Schedule Twilio call

I currently am able to make a call using the Twilio API with the following python code:

#Download the library from twilio.com/docs/libraries
from twilio.rest import TwilioRestClient

# Get these credentials from http://twilio.com/user/account
account_sid = "myaccountsid"
auth_token = "myauthtoken"
client = TwilioRestClient(account_sid, auth_token)

# Make the call
call = client.calls.create(to="+12345789123",  # Any phone number
                           from_="+12345789123", # Must be a valid Twilio number
                           url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient")
print call.sid

Now I want to schedule this code to be executed at a particular time. What's the easiest way to do this?

Upvotes: 1

Views: 581

Answers (1)

Jacob Budin
Jacob Budin

Reputation: 10003

The easiest way? If you're running a Unix-like OS, the easiest way is with at:

$ echo "python script.py" | at 1400

The command above executes script.py at 2 p.m. system time. (Note: Some OSs, such as OS X, disable atrun execution by default; you may need to enable it. See $ man atrun for help.)

This is a very primitive solution. Alternatives include using your OS's init functionality (including via cron) or constructing a daemon.

Upvotes: 1

Related Questions