Getting started¶
This tutorial shows how to send your first signed requests. When you complete it, you know that your keys and your IP addresses work, and that your code calculates the signature correctly.
Time: about 20 minutes.
Before you start¶
Make sure that you have:
- Your test credentials: a partner ID, a public key, a private key and the test service IDs. See Credentials.
- A server with an IP address that MEGOGO added to the list of your test partner ID.
- A test SIM card. You need its phone number.
- Python 3 on the server. The examples use the code from Sign a request.
WARNING
The test partner ID works on the production servers. Use only the phone number of your test SIM card.
Step 1. Calculate the signature¶
Copy the functions terminals_sign and signed_url from
Sign a request. Run the worked example. Make sure
that your result is the same as the URL in step 6 of the worked example.
Step 2. Get your services¶
Send subscriptions without a phone number:
print(signed_url("/terminals/{partner_id}/subscriptions", {},
"{private_key}", "{public_key}"))
curl "https://billing.megogo.net/terminals/{partner_id}/subscriptions?sign={sign}"
Expected response (shortened):
[
{
"serviceId": "example_light_30d",
"serviceName": "Light (partner)",
"serviceDescription": "TV channels and a movie collection",
"tariff": {"tariffId": 12345, "tariffName": "30 days", "price": 0, "tryAndBuy": false},
"dateFinish": -1,
"dateFinishString": "1969-12-31 23:59:59"
}
]
- The list contains the services that MEGOGO configured for your partner
ID. Find your test service IDs in
serviceId. - If a service ID from your MEGOGO manager is not in the list, tell your MEGOGO manager.
If you get HTTP 401, see Troubleshooting.
Step 3. Check your test phone number¶
curl "https://billing.megogo.net/terminals/{partner_id}/user/phone?phone={phone}&sign={sign}"
| Response | Meaning |
|---|---|
{"successful": true} |
MEGOGO has a user with this phone number |
{"successful": false, "message": "User doesn't not exist"} |
The phone number is not registered in MEGOGO. The text is as the API gives it |
Step 4. Activate a test subscription¶
Send subscribe with your test phone number and a test service ID:
curl "https://billing.megogo.net/terminals/{partner_id}/subscription/subscribe?phone={phone}&serviceId={service_id}&sign={sign}"
Expected response:
{"successful": true}
If the phone number was not registered, MEGOGO created the user.
Step 5. Check the subscription¶
curl "https://billing.megogo.net/terminals/{partner_id}/subscriptions?phone={phone}&sign={sign}"
The response contains your service with the end date in dateFinish
(Unix time) and dateFinishString (UTC).
Step 6. Sign in to MEGOGO¶
- Open a MEGOGO application or the MEGOGO website.
- Select the sign-in with a phone number.
- Enter your test phone number. Enter the one-time code from SMS or Viber.
- Make sure that the subscription is in the profile and that a video of the subscription plays.
Step 7. Stop the subscription¶
curl "https://billing.megogo.net/terminals/{partner_id}/subscription/unsubscribe?phone={phone}&serviceId={service_id}&sign={sign}"
Expected response: {"successful": true}. Do step 5 again: the response is
[].
Next steps¶
- Subscription lifecycle: renewal modes and states of a subscription.
- Activate a subscription for your users.
- Renew, suspend and stop a subscription.
Guide version 1.0.0, 2026-11-02 · Report a problem on this page