Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. import csv
  2. import json
  3. import requests
  4.  
  5.  
  6.  
  7. ##########File reading on a push of a button(Load Data)
  8. contactFile = open("contacts.csv", 'r')
  9. contacts = contactFile.read()
  10. contactFile.close()
  11. contacts = contacts.split('\n')
  12.  
  13. goodContacts = []
  14.  
  15. messageFile = open("data.txt", 'r')
  16. messages = messageFile.read()
  17. messages = messages.split('\n')
  18. access_token = messages[0]
  19. access_token = access_token.strip()
  20.  
  21. ###############
  22.  
  23.  
  24. #Start sending the messages button(Start sending)
  25. for phoneNum in contacts:
  26. if phoneNum.__len__() > 1:
  27. message = messages[1]
  28. phoneNum = "+" + phoneNum
  29. recipient = {"phone_number": phoneNum}
  30. message = {"text": message}
  31. headers = {'Content-Type': 'application/json'}
  32. url = 'https://graph.facebook.com/v2.6/me/messages?access_token=' + access_token
  33. data = {"recipient": recipient, "message": message}
  34. dat = json.dumps(data)
  35. r = requests.post(url, data=dat, headers=headers)
  36. print(r)
  37. if(str(r).__contains__('200')):
  38. print ('Message sent to: ') + str(phoneNum)
  39. goodContacts.append(phoneNum)
  40. del r
  41. with open('MatchingContacts.csv', 'a') as csvfile:
  42. spamwriter = csv.writer(csvfile, delimiter=' ', quotechar=' ')
  43. for contact in goodContacts:
  44. spamwriter.writerow(["Message Sent"] + [contact])
  45.  
  46. #After sending a popup shows that the messages have been sent to all the matching contacts
  47. # and matching contacts have been saved to Matching Contacts file
  48.  
  49.  
  50. # 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