Phone

Access user phone number

get
Get phone number

https://connect.synaps.io/v1/resources/phone
Return phone number
Request
Response
Headers
Authorization
required
string
User access token Example : Bearer {access_token}
Content-Type
optional
string
application/json
200: OK
Valid authorized user
{
"data": {
"phone_number": "653543465",
"country_code": "33",
"state": "VERIFIED"
},
"status": {
"error": false,
"api_code": "SUCCESS",
"type": "success",
"message": "success"
}
}
400: Bad Request
Invalid authorization code
{
"data": null,
"status": {
"error": true,
"api_code": "INVALID_AUTHORIZATION_CODE",
"type": "error",
"message": "Invalid authorization code"
}
}
401: Unauthorized
Unauthorized scope
{
"data": null,
"status": {
"error": true,
"api_code": "UNAUTHORIZED_SCOPE",
"type": "error",
"message": "Unauthorized scope"
}
}

API Response

Field

Type

Description

phone_number

string

Phone number

country_code

string

Country code (see full country code list in reference)

state

string

PENDING - pending confirmation

NOT_SUBMITTED - not yet submitted

VERIFIED - verified

Code Snippets

cURL
Java
Javascript
Node.js
Python
PHP
Ruby
Go
C#
curl --include \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Bearer access_token" \
'https://connect.synaps.io/v1/resources/phone'
// Maven : Add these dependecies to your pom.xml (java6+)
// <dependency>
// <groupId>org.glassfish.jersey.core</groupId>
// <artifactId>jersey-client</artifactId>
// <version>2.8</version>
// </dependency>
// <dependency>
// <groupId>org.glassfish.jersey.media</groupId>
// <artifactId>jersey-media-json-jackson</artifactId>
// <version>2.8</version>
// </dependency>
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
Client client = ClientBuilder.newClient();
Response response = client.target("https://connect.synaps.io/v1/resources/phone")
.request(MediaType.APPLICATION_JSON_TYPE)
.header("Accept", "application/json")
.header("Authorization", "Bearer access_token")
.get();
System.out.println("status: " + response.getStatus());
System.out.println("headers: " + response.getHeaders());
System.out.println("body:" + response.readEntity(String.class));
var request = new XMLHttpRequest();
request.open('GET', 'https://connect.synaps.io/v1/resources/phone');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('Authorization', 'Bearer access_token');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
request.send();
var request = require('request');
request({
method: 'GET',
url: 'https://connect.synaps.io/v1/resources/phone',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer access_token'
}}, function (error, response, body) {
console.log('Status:', response.statusCode);
console.log('Headers:', JSON.stringify(response.headers));
console.log('Response:', body);
});
from urllib2 import Request, urlopen
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer access_token'
}
request = Request('https://connect.synaps.io/v1/resources/phone', headers=headers)
response_body = urlopen(request).read()
print response_body
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://connect.synaps.io/v1/resources/phone");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Accept: application/json",
"Authorization: Bearer access_token"
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
headers = {
:content_type => 'application/json',
:accept => 'application/json',
:authorization => 'Bearer access_token'
}
response = RestClient.get 'https://connect.synaps.io/v1/resources/phone', headers
puts response
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://connect.synaps.io/v1/resources/phone", nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer access_token")
resp, err := client.Do(req)
if err != nil {
fmt.Println("Errored when sending request to the server")
return
}
defer resp.Body.Close()
resp_body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(resp.Status)
fmt.Println(string(resp_body))
}
//Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
//System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
using System;
using System.Net.Http;
var baseAddress = new Uri("https://connect.synaps.io/");
using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("authorization", "Bearer access_token");
using(var response = await httpClient.GetAsync("v1/resources/phone"))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}