69 lines
1.5 KiB
PHP
69 lines
1.5 KiB
PHP
![]() |
<?php
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* Class ki vsebuje funkcije APIJA (prijava, registracija v 1ko)
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
class SqualoApi {
|
||
|
|
||
|
// Squalo api url
|
||
|
var $api_url = 'https://api.squalomail.com/v1/';
|
||
|
|
||
|
|
||
|
public function __construct(){
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
public function executeCall($action, $method, $data){
|
||
|
global $squalo_user;
|
||
|
global $squalo_key;
|
||
|
|
||
|
// Add credentials
|
||
|
$data['apiKey'] = $squalo_key;
|
||
|
$data['apiUser'] = $squalo_user;
|
||
|
|
||
|
$params = '';
|
||
|
|
||
|
// GET call - set url params
|
||
|
if($method == 'GET'){
|
||
|
|
||
|
$params .= '?';
|
||
|
|
||
|
// GET params
|
||
|
foreach($data as $name => $value){
|
||
|
$params .= '&'.$name.'='.$value;
|
||
|
}
|
||
|
|
||
|
$params = substr($params, 1);
|
||
|
}
|
||
|
|
||
|
// Init curl
|
||
|
$ch = curl_init($this->api_url.$action.$params);
|
||
|
|
||
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||
|
|
||
|
// POST call - set curl data
|
||
|
if($method == 'POST'){
|
||
|
// JSON string za POST
|
||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||
|
|
||
|
curl_setopt($ch, CURLOPT_POST, true);
|
||
|
|
||
|
curl_setopt($ch, CURLOPT_HEADER , 1);
|
||
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1);
|
||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||
|
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
|
||
|
}
|
||
|
|
||
|
// Izvedemo klic
|
||
|
$result = curl_exec($ch);
|
||
|
|
||
|
return $result;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|