Targeting & Calculation
This request allows you to calculate targeting and its cost.
URL
POST https://api.smspartner.fr/v1/location/optin
Parameters
apiKey
op
Operation to perform:
calcul: Calculate the cost and number of contacts matching the targetingprice: Calculate the cost of targeting onlyrent: Rent a contact database
parameters
sexe :
Gender of targeted contacts, must be:
– m (mixed)
– or h (male)
– or f (female)
minAge :
Minimum age of the target, must be greater than 18.
maxAge :
Maximum age of the target, must be less than 99.
interest :
Main category of the target.
subInterest (optional) :
Subcategory of the main category
category (optional) :
Socio-professional category:
– 102: CSP+
– 103: CSP-
department (optional) :
List of targeted departments. e.g.: 02,60, etc…
zipcode (optional) :
List of targeted zip codes. e.g.: 02200,60200, etc…
volumes
This parameter is only available if op = rent or price.
Allows you to choose a desired volume per postal code or department
Requests
<?php
// Prepare data for POST request
$fields = array(
'apiKey'=> 'YOUR API KEY',
'op':'calcul',
'parameters':{
'sexe'=> 'm',
'minAge'=> '25',
'maxAge' => '35',
'zipcode'=> '60200',
'interest'=> 14, /*Habitation*/
'subInterest'=> 35 /*Cuisine*/
},
'volumes':{
'60200':20
}
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/location/optin');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS,json_encode($fields));
$result = curl_exec($curl);
curl_close($curl);
// Process your response here
echo $result;
?>Imports System.IO
Imports System.Net
Module Module1
Sub Main()
Dim base_url As String = "http://api.smspartner.fr/v1/"
Dim apiKey As String = "YOUR API KEY"
#send sms
url = base_url & "location/optin"
#note : utiliser une librairie JSON en production, par exemple :
#https//www.nuget.org/packages/Newtonsoft.Json/
Dim parameters As String = String.Format(
"{{""apiKey"":""{0}"",""op"":""{1}"",""parameters"":""{2}"",""volumes"":""{3}""}}",
apiKey,
"price",
"{ "sexe"=> "m","minAge"=> "25","maxAge" => "35","zipcode"=> "60200","interest"=> 14,"subInterest"=> 35}",
"{"60200":20}"
)
""
Console.Write(parameters)
apiRequest("POST", url, parameters)
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# std
import http.client
conn = http.client.HTTPConnection("api,smspartner,fr")
payload = "{"apiKey":"YOUR API KEY","op":"price","parameters":{"sexe":"f","minAge":25,"maxAge":35,"zipcode":"06200","interest":12,"subInterest":29,"category":103},"volumes":{"60200":20}}"
headers = {
"Content-Type": "application/json"
}
conn.request("POST", "v1,location,optin", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))curl -X POST https://api.smspartner.fr/v1/location/optin -H "Content-Type: application/json" -d '{"apiKey":"YOUR API KEY","op":"price","parameters":{"sexe":"f","minAge":25,"maxAge":35,"zipcode":"06200","interest":"12","subInterest":"29","category":103}}Response
{
"success": true,
"op": "price",
"datas": [
{
"Type": "CP",
"Localite": "06200",
"Volume": 20
},
{
"Type": "total",
"Localite": "total",
"Volume": 20
}
],
"cost": {
"quantity": 20,
"total": 2.52,
"cost_unity": 0.09
}
}<?xml version="1.0" encoding="UTF-8"?>
<result>
<entry>true</entry>
<entry>
<![CDATA[price]]>
</entry>
<entry>
<entry>
<entry>
<![CDATA[CP]]>
</entry>
<entry>
<![CDATA[06200]]>
</entry>
<entry>28</entry>
</entry>
<entry>
<entry>
<![CDATA[total]]>
</entry>
<entry>
<![CDATA[total]]>
</entry>
<entry>28</entry>
</entry>
</entry>
<entry>
<entry>28</entry>
<entry>2.52</entry>
<entry>0.09</entry>
</entry>
</result>Errors
{
"success": false,
"code": 10,
"message": "Clé API incorrecte"
}<?xml version="1.0" encoding="UTF-8"?>
<result>
<entry>false</entry>
<entry>10</entry>
<entry>
<![CDATA[Clé API incorrecte]]>
</entry>
</result>Error Codes
1
API key is required
10
Invalid API key
200
Operation completed
Last updated