forked from sriharrsha/flipside.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flipsideio.php
76 lines (60 loc) · 2.15 KB
/
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?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 developerowl;
chdir(dirname(__DIR__)); //GO TO CURRENT WORKING DIR
require 'vendor/autoload.php';
include("flipsidejsonclient.php");
include("flipsidexmlclient.php");
class FlipsideIO {
protected $fkAffiliateId;
protected $fkAffiliateToken;
protected $responseType;
protected $apiBaseUrl = 'https://affiliate-api.flipkart.net/affiliate/api/';
protected $apiRequestUrl;
protected $verifySsl = false;
protected $responseCode;
protected $io;
protected $client;
public function __construct($fkAffiliateId, $fkAffiliateToken, $responseType = 'json') {
$this->fkAffiliateId = $fkAffiliateId;
$this->fkAffiliateToken = $fkAffiliateToken;
$this->responseType = $responseType;
//Add the affiliateId and response_type to the base URL to complete it.
$this->apiRequestUrl.=$this->apiBaseUrl.$this->fkAffiliateId.'.'.$this->responseType;
if ($responseType == 'xml') {
//echo "XML Clients Created";
$this->io = new FlipsideXMLClient($fkAffiliateId, $fkAffiliateToken);
} else if ($responseType == 'json') {
//echo "JSON Clients Created";
$this->io = new FlipsideJSONClient($fkAffiliateId, $fkAffiliateToken);
} else {
//echo "No Clients Available";
return null;
}
}
function makeRequest1() {
//echo get_class($this->io);
$this->io->makeRequest();
}
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
$flip = new FlipsideIO('nathgopin', '0bbdf4bcaafd4ab6879f46c181caade5', 'xml');
$flip->makeRequest1();
?>