Authentication¶
In order to work with the PhotoILike API it is necessary to use a session token in the requests. The only request that does not require the session token is the one generated by the token itself.
Request
POST https://api.photoilike.com/v2.0/authenticate
Body of the application
The body of the request contains data with the following structure:
JSON representation
Fields
Parameter | Information |
---|---|
username | string Required. PhotoILike User. |
password | string Required. PhotoILike Password. |
Response to the request
On success, the HTTP status code in the response header is 200 OK and the response body contains the session token.
JSON representation
Fields
Parameter | Information |
---|---|
id_token | string Session token. |
Example of a request
import requests
payload = {
# Add your photoilike user
'username': 'YOUR_USERNAME',
# Add your photoilike password
'password': 'YOUR_PASSWORD'
}
endpoint = 'https://api.photoilike.com/v2.0/authenticate'
# Make the request
r = requests.post(endpoint, json=payload)
# Response in json format
response = r.json()
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import org.json.JSONObject;
public class Authenticate {
public static void main(String []args) throws Exception {
JSONObject payload = new JSONObject();
// add your photoilike user
payload.put("username", "YOUR_USERNAME");
// add your photoilike password
payload.put("password", "YOUR_PASSWORD");
String endpoint = "https://api.photoilike.com/v2.0/authenticate";
// build the request
HttpURLConnection connection = (HttpURLConnection) new URL(endpoint).openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setDoOutput(true);
OutputStream os = connection.getOutputStream();
byte[] input = payload.toString().getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
// make the request
BufferedReader br = new BufferedReader(
new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)
);
StringBuilder response = new StringBuilder();
for (String responseLine = null; (responseLine = br.readLine()) != null; response.append(responseLine.trim()))
;
// Response in json format
JSONObject json = new JSONObject(response.toString());
}
}
<?php
// Add your photoilike user
// Add your photoilike password
$payload = json_encode(array(
'username' => 'YOUR_USERNAME',
'password' => 'YOUR_PASSWORD'
));
$endpoint = "https://api.photoilike.com/v2.0/authenticate";
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Make the request
$result = curl_exec($ch);
curl_close($ch);
// Response in json format
$response = json_decode($result);
?>