Crédits
- Home
- Crédits
Introdução ao Parceiro API SMS
Esta consulta é usado para recuperar seu crédito SMS disponível e o número de pendente de início SMS.
URLs
GET https://api.smspartner.fr/v1/me
Configurações
Cada solicitação de API suporta os seguintes parâmetros :
apiKey | Chave de API da sua conta. Você obtê-lo em seu parceiro de conta SMS. |
---|---|
Configurações opcionais | |
_formato | Formato de resposta. Você pode escolher entre json ou xml. Por padrão, o formato de resposta é JSON. |
Petição
Consulta de exemplo :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php // Prepare data for GET request $data = 'apiKey=YOUR_API_KEY'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/me?'.$data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $result = curl_exec($curl); curl_close($curl); // Process your response here echo $result; ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
cURL Imports System.IO Imports System.Net Module Module1 Sub Main() Dim base_url As String = "http://api.smspartner.fr/v1/" Dim apiKey As String = "VOTRE_APIKEY" #check credits Dim url As String url = base_url & "me" & "?apiKey=" & apiKey Dim credits As String credits = apiRequest("GET", url, Nothing) End Sub Function apiRequest(method As String, url As String, parameters As String) As String Dim request As HttpWebRequest request = WebRequest.Create(url) request.Method = method request.Timeout = 10000 # timeout in ms request.ContentType = "application/json; charset=utf-8" request.ContentLength = 0 #set POST data If Not String.IsNullOrEmpty(parameters) Then request.ContentLength = parameters.Length Using reqStream As StreamWriter = New StreamWriter(request.GetRequestStream()) reqStream.Write(parameters) End Using End If #get response Dim returnValue As String = Nothing Using response As HttpWebResponse = request.GetResponse() If response.StatusCode = HttpStatusCode.OK Then Using resStream = response.GetResponseStream() If resStream IsNot Nothing Then Using reader As New StreamReader(resStream) returnValue = reader.ReadToEnd() End Using End If End Using End If End Using apiRequest = returnValue End Function End Module |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# std import logging import json from collections import OrderedDict # 3p import requests API_KEY = "MY API KEY" URL = "https://api.smspartner.fr/v1" class SMSPartner(): def get_balance(self): url = URL + "/me?apiKey=" + API_KEY r = requests.get(url) r_json = r.json() if r_json.get("success") == True: print(r_json) status = True else: print(r_json) status = False return status |
1 |
curl -H "Content-Type: application/json" -X GET https://api.smspartner.fr/v1/me?apiKey=xxx |
Respostas
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
{ "success": true, "code": 200, "user": { "username": "exemple@email.com", "firstname": "John", "lastname": "Doe" }, "credits": { "creditSms": 269082, "creditSmsLowCost": 444570, "creditHlr": 2045023, "toSend": 0, "solde": "10225.119", "currency": "EUR", "balance": "10225.119" } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?xml version='1.0' encoding='UTF-8'?> <result> <entry>true</entry> <entry>200</entry> <entry> <username>exemple@email.com</username> <firstname>John</firstname> <lastname>Doe</lastname> </entry> <entry> <entry>269070</entry> <entry>444551</entry> <entry>2044937</entry> <entry>0</entry> <entry> <![CDATA[10224.688]]> </entry> <entry> <![CDATA[EUR]]> </entry> <entry> <![CDATA[10224.688]]> </entry> </entry> </result> |
Código de controle
_ | Resposta |
---|---|
10 | Chave de API inválida |
200 | Tudo correu bem! |