0% found this document useful (0 votes)
158 views3 pages

Smsbower - Online Request API

The document contains Python code for interacting with the SMS Bower API, allowing users to check their account balance, request a phone number for verification services, and retrieve SMS codes. It includes error handling for invalid API keys and unexpected responses. The code demonstrates how to make GET requests to the API and process the responses accordingly.

Uploaded by

jasirjabbar789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
158 views3 pages

Smsbower - Online Request API

The document contains Python code for interacting with the SMS Bower API, allowing users to check their account balance, request a phone number for verification services, and retrieve SMS codes. It includes error handling for invalid API keys and unexpected responses. The code demonstrates how to make GET requests to the API and process the responses accordingly.

Uploaded by

jasirjabbar789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

smsbower.

online

Balance

import requests

# Replace 'YOUR_API_KEY' with your actual API key


api_key = ''

# API endpoint
url = f'https://smsbower.online/stubs/handler_api.php?
api_key={api_key}&action=getBalance'

try:
# Send a GET request to the API
response = requests.get(url)

# Check if the request was successful


if response.status_code == 200:
# Print the API response
result = response.text
if result.startswith("ACCESS_BALANCE"):
# Extract balance from response
balance = result.split(":")[1]
print(f"Your account balance is: {balance}")
elif result == "BAD_KEY":
print("Error: Invalid API key")
else:
print(f"Unexpected response: {result}")
else:
print(f"Failed to connect to API. Status code: {response.status_code}")

except Exception as e:
print(f"An error occurred: {e}")

Request Number

import requests

# Your API Key


api_key = ''

# Parameters
service = 'go' # e.g., 'go' for Google, Gmail, Youtube
country = '0' # e.g., '0' for Russian Federation
max_price = '10' # Maximum price you're ready to pay
phone_exception = '' # Exclude certain phone numbers, leave empty if not needed
ref = '' # Referral ID, leave empty if not applicable

# API endpoint
url = f'https://smsbower.online/stubs/handler_api.php?
api_key={api_key}&action=getNumber&service={service}&country={country}&maxPrice={ma
x_price}&phoneException={phone_exception}&ref={ref}'

try:
# Send a GET request to the API
response = requests.get(url)

# Check if the request was successful


if response.status_code == 200:
# Print the API response
result = response.text
if result.startswith("ACCESS_NUMBER"):
# Extract activation ID and phone number from the response
parts = result.split(":")
activation_id = parts[1]
phone_number = parts[2]
print(f"Activation ID: {activation_id}")
print(f"Phone Number: {phone_number}")
elif result == "BAD_KEY":
print("Error: Invalid API key")
elif result == "BAD_ACTION":
print("Error: Incorrect action")
elif result == "BAD_SERVICE":
print("Error: Incorrect service name")
else:
print(f"Unexpected response: {result}")
else:
print(f"Failed to connect to API. Status code: {response.status_code}")

except Exception as e:
print(f"An error occurred: {e}")

Request Code
import requests
import time

# Your API Key


api_key = ''

# Parameters for getting the number


service = 'go' # e.g., 'go' for Google, Gmail, Youtube
country = '0' # e.g., '0' for Russian Federation
max_price = '10' # Maximum price you're ready to pay
phone_exception = '' # Exclude certain phone numbers, leave empty if not needed
ref = '' # Referral ID, leave empty if not applicable

# API endpoint for getting the number


get_number_url = f'https://smsbower.online/stubs/handler_api.php?
api_key={api_key}&action=getNumber&service={service}&country={country}&maxPrice={ma
x_price}&phoneException={phone_exception}&ref={ref}'

try:
# Step 1: Get a phone number
response = requests.get(get_number_url)

if response.status_code == 200:
result = response.text
if result.startswith("ACCESS_NUMBER"):
# Extract activation ID and phone number from the response
parts = result.split(":")
activation_id = parts[1]
phone_number = parts[2]
print(f"Phone Number: {phone_number}")
print(f"Activation ID: {activation_id}")

# Step 2: Poll for SMS code using the activation ID


get_status_url = f'https://smsbower.online/stubs/handler_api.php?
api_key={api_key}&action=getStatus&id={activation_id}'

# Poll for the SMS code with a delay


while True:
status_response = requests.get(get_status_url)
if status_response.status_code == 200:
status_result = status_response.text
if status_result.startswith("STATUS_WAIT_CODE"):
print("Waiting for SMS...")
elif status_result.startswith("STATUS_WAIT_RESEND"):
print("Waiting for next SMS...")
elif status_result.startswith("STATUS_OK"):
# Extract and print the received activation code
code = status_result.split(":")[1].strip()
print(f"Activation Code: {code}")
break
elif status_result == "STATUS_CANCEL":
print("Activation canceled.")
break
elif status_result == "NO_ACTIVATION":
print("Incorrect activation ID.")
break
else:
print(f"Unexpected status response: {status_result}")
else:
print(f"Failed to check status. Status code:
{status_response.status_code}")

# Wait for 10 seconds before checking again


time.sleep(10)

elif result == "BAD_KEY":


print("Error: Invalid API key")
elif result == "BAD_ACTION":
print("Error: Incorrect action")
elif result == "BAD_SERVICE":
print("Error: Incorrect service name")
else:
print(f"Unexpected response: {result}")

else:
print(f"Failed to connect to API. Status code: {response.status_code}")

except Exception as e:
print(f"An error occurred: {e}")

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy