Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- import json
- import requests
- ##########File reading on a push of a button(Load Data)
- contactFile = open("contacts.csv", 'r')
- contacts = contactFile.read()
- contactFile.close()
- contacts = contacts.split('\n')
- goodContacts = []
- messageFile = open("data.txt", 'r')
- messages = messageFile.read()
- messages = messages.split('\n')
- access_token = messages[0]
- access_token = access_token.strip()
- ###############
- #Start sending the messages button(Start sending)
- for phoneNum in contacts:
- if phoneNum.__len__() > 1:
- message = messages[1]
- phoneNum = "+" + phoneNum
- recipient = {"phone_number": phoneNum}
- message = {"text": message}
- headers = {'Content-Type': 'application/json'}
- url = 'https://graph.facebook.com/v2.6/me/messages?access_token=' + access_token
- data = {"recipient": recipient, "message": message}
- dat = json.dumps(data)
- r = requests.post(url, data=dat, headers=headers)
- print(r)
- if(str(r).__contains__('200')):
- print ('Message sent to: ') + str(phoneNum)
- goodContacts.append(phoneNum)
- del r
- with open('MatchingContacts.csv', 'a') as csvfile:
- spamwriter = csv.writer(csvfile, delimiter=' ', quotechar=' ')
- for contact in goodContacts:
- spamwriter.writerow(["Message Sent"] + [contact])
- #After sending a popup shows that the messages have been sent to all the matching contacts
- # and matching contacts have been saved to Matching Contacts file
- # In the about tab it will be written that message will only be sent to those who have their contacts attched to FB accountOkay very nice we are set I will just send you the source code and then run it wait Okay go check fiverr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement