Last active
January 6, 2023 20:47
-
-
Save alsak0de/993c0390136836cd148090ede4426936 to your computer and use it in GitHub Desktop.
Basic python code to use whin (whatsapp self messaging)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def sendWSP(message, apikey,gid=0): | |
url = "https://whin2.p.rapidapi.com/send" | |
headers = { | |
"content-type": "application/json", | |
"X-RapidAPI-Key": apikey, | |
"X-RapidAPI-Host": "whin2.p.rapidapi.com"} | |
try: | |
if gid==0: | |
return requests.request("POST", url, json=message, headers=headers) | |
else: | |
url = "https://whin2.p.rapidapi.com/send2group" | |
querystring = {"gid":gid} | |
return requests.request("POST", url, json=message, headers=headers, params=querystring) | |
except requests.ConnectionError: | |
return("Error: Connection Error") | |
# Testing Section | |
msg1 = {"text":"hello there"} | |
msg2 = {"text":"this is a group message"} | |
myapikey = "your_api_key" | |
mygroup = "your_wsp_group_id" | |
sendWSP(msg1,myapikey) | |
sendWSP(msg2, myapikey,mygroup) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment