Bu cevap, konu sahibi tarafından kabul edilebilir bir cevap olarak işaretlendi.
Twitter API ile tweet'leri çekip,
Twilio ile SMS gönder
import tweepy
from twilio.rest import Client
# Twitter API kimlik bilgileri
consumer_key = 'YOUR_TWITTER_CONSUMER_KEY'
consumer_secret = 'YOUR_TWITTER_CONSUMER_SECRET'
access_token = 'YOUR_TWITTER_ACCESS_TOKEN'
access_token_secret = 'YOUR_TWITTER_ACCESS_TOKEN_SECRET'
# Twilio API kimlik bilgileri
account_sid = 'YOUR_TWILIO_ACCOUNT_SID'
auth_token = 'YOUR_TWILIO_AUTH_TOKEN'
# Twitter API'ye bağlan
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
# Twilio istemcisi oluştur
client = Client(account_sid, auth_token)
# Belirli bir kullanıcının son tweet'ini çek
def get_latest_tweet(username):
tweets = api.user_timeline(screen_name=username, count=1, tweet_mode="extended")
if tweets:
return tweets[0].full_text
return None
# SMS gönderme fonksiyonu
def send_sms(body, to):
message = client.messages.create(
body=body,
from_='YOUR_TWILIO_PHONE_NUMBER', # Twilio numaranız
to=to # Alıcının telefon numarası
)
print(f"Message sent: {message.sid}")
# Belirli kullanıcıların tweet'lerini al ve SMS olarak gönder
def send_tweet_via_sms(username, phone_number):
tweet = get_latest_tweet(username)
if tweet:
send_sms(tweet, phone_number)
else:
print("Tweet bulunamadı veya kullanıcı tweet atmamış.")
# Kullanıcı bilgileri
twitter_username = 'twitter_username' # Takip etmek istediğiniz Twitter kullanıcı adı
phone_number = '+1234567890' # SMS gönderilecek telefon numarası
# Tweet'i al ve SMS olarak gönder
send_tweet_via_sms(twitter_username, phone_number)