forked from sriharrsha/flipside.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sriharrsha.flipsideio.php
58 lines (47 loc) · 1.84 KB
/
sriharrsha.flipsideio.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
51
52
53
54
55
56
57
58
<?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 FlipsideIO
{
use GuzzleHttp\Client;
private $fkAffiliateId;
private $fkAffiliateToken;
private $responseType;
private $apiBaseUrl = 'https://affiliate-api.flipkart.net/affiliate/api/';
private $apiRequestUrl;
private $verifySsl = false;
public
function __construct($fkAffiliateId, $fkAffiliateToken, $responseType='json')
{
$this->fkAffiliateToken = $fkAffiliateId;
$this->fkAffiliateToken = $fkAffiliateToken;
//Add the affiliateId and response_type to the base URL to complete it.
$this->apiRequestUrl.=$this->apiBaseUrl.'.'.$this->affiliateId.'.'.$this->responseType;
if($responseType=='xml'){
return new FlipsideXMLClient();
}
else{
return new FlipsideJSONClient();
}
}
function returnApiError(){
switch($responseCode){
case 410: echo 'URL expired';
break;
case 401: echo 'API Token or Affiliate Tracking ID invalid';
break;
case 403: echo 'Tampered URLThe URL contents are modified from the originally returned value';
break;
}
}
}//End Of Class
?>