forked from sriharrsha/flipside.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sriharrsha.flipsidejsonclient.php
50 lines (39 loc) · 1.63 KB
/
sriharrsha.flipsidejsonclient.php
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
<?php
/**
* PHP Client for Flipkart Affilate API-[FLIPSIDE.IO]
* GitHub: https://github.com/sriharrsha/flipside.io
* License: MIT License
*
* @author Sri Harrsha <[email protected]>
* @version 0.1
*/
namespace sriharrsha;
chdir(dirname(__DIR__));
require 'vendor/autoload.php';
class FlipsideJSONClient extends FlipsideIO
{
use GuzzleHttp\Client;
//JSON Client Constructor
function __construct($fkAffiliateId, $fkAffiliateToken, $responseType="json")
{
super($fkAffiliateId,$fkAffiliateToken);
$this->response_type = $responseType;
//Add the affiliateId and response_type to the base URL to complete it.
$this->apiRequestUrl.=$this->apiBaseUrl.'.'.$this->affiliateId.'.'.$this->responseType;
$client = new Client();
}
//Make Request to API
function makeRequest(){
$request = $client->createRequest('GET', $this->apiRequestUrl);
$request->setHeader('Content-Type', 'application/json');
$request->setHeader('Cache-Control: no-cache');
$request->setHeader('Fk-Affiliate-Id',$this->fkAffiliateToken);
$request->setHeader('Fk-Affiliate-Token',$this->fkAffiliateToken);
$response = $client->send($request);
if(($responseCode==410)||($responseCode==403)||($responseCode==401)){
returnApiError($responseCode);
}
return $response->xml();
}
}//End Of Class
?>