forked from swaroopv/Android-App-for-eBay-Search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
163 lines (150 loc) · 6.24 KB
/
index.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
//require_once('FirePHPCore/fb.php');
//ob_start();
//error_reporting(0);
//fb("hello");
define("APP_ID", "student6b-3af5-4e84-8b08-541cbaf6c51") ;
$myURL = 'http://svcs.ebay.com/services/search/FindingService/v1?';
$options = array(
"siteid" => "0",
"SECURITY-APPNAME" => APP_ID,
"OPERATION-NAME" => "findItemsAdvanced",
"SERVICE-VERSION" => "1.0.0",
"RESPONSE-DATA-FORMAT" => "XML",
"keywords" => $_GET["Keywords"]
);
$itemFilterCount = 0;
$x = 0;
// $options["itemFilter(".$itemFilterCount.").paramName"] = "Currency";
// $options["itemFilter(".$itemFilterCount.").paramValue"] = "XML";
// ++$itemFilterCount;
if(!empty($_GET["minPrice"])){
$options["itemFilter(".$itemFilterCount.").name"] = "MinPrice";
$options["itemFilter(".$itemFilterCount.").value"] = $_GET["minPrice"];
++$itemFilterCount;
}
if(!empty($_GET["maxPrice"])){
$options["itemFilter(".$itemFilterCount.").name"] = "MaxPrice";
$options["itemFilter(".$itemFilterCount.").value"] = $_GET["maxPrice"];
++$itemFilterCount;
}
if(!empty($_GET['condition'])){
$options["itemFilter(".$itemFilterCount.").name"] = "Condition";
foreach($_GET['condition'] as $condition) {
$options["itemFilter(".$itemFilterCount.").value(".$x.")"] = $condition;
++$x;
}
++$itemFilterCount;
$x =0;
}
if(!empty($_GET['ListingType'])){
$options["itemFilter(".$itemFilterCount.").name"] = "ListingType";
$x = 0;
foreach($_GET['ListingType'] as $ListingType) {
$options["itemFilter(".$itemFilterCount.").value(".$x.")"] = $ListingType;
++$x;
}
++$itemFilterCount;
$x = 0;
}
if(isset($_GET["ReturnsAcceptedOnly"])){
$options["itemFilter(".$itemFilterCount.").name"] = "ReturnsAcceptedOnly";
$options["itemFilter(".$itemFilterCount.").value"] = $_GET["ReturnsAcceptedOnly"];
++$itemFilterCount;
}
if(isset($_GET["FreeShippingOnly"])){
$options["itemFilter(".$itemFilterCount.").name"] = "FreeShippingOnly";
$options["itemFilter(".$itemFilterCount.").value"] = $_GET["FreeShippingOnly"];
++$itemFilterCount;
}
if(isset($_GET["ExpeditedShippingType"])){
$options["itemFilter(".$itemFilterCount.").name"] = "ExpeditedShippingType";
$options["itemFilter(".$itemFilterCount.").value"] = $_GET["ExpeditedShippingType"];
++$itemFilterCount;
}
if(!empty($_GET["MaxHandlingTime"])){
$options["itemFilter(".$itemFilterCount.").name"] = "MaxHandlingTime";
$options["itemFilter(".$itemFilterCount.").value"] = $_GET["MaxHandlingTime"];
++$itemFilterCount;
}
if(isset($_GET["sortOrder"])){
$options["sortOrder"] = $_GET["sortOrder"];
}
if(isset($_GET["entriesPerPage"])){
$options["paginationInput.entriesPerPage"] = $_GET["entriesPerPage"];
}
$options["outputSelector(1)"] = "SellerInfo";
$options["outputSelector(2)"] = "PictureURLSuperSize";
$options["outputSelector(3)"] = "StoreInfo";
$options["outputSelector(2)"] = "PictureURLSuperSize";
$options["paginationInput.pageNumber"] = $_GET["pageNumber"];
$myURL .= http_build_query($options,'','&');
//echo $myURL;
$response = file_get_contents($myURL) or die(print_r(error_get_last()));
//echo $response;
$xml = simplexml_load_string($response);
echo "{";
if($xml->ack == "Success" && intval( $xml->searchResult['count']) == 0)
echo "\"ack\":\"No results found\"";
else
echo "\"ack\":\"".$xml->ack."\"";
if($xml->ack == "Success" && intval( $xml->searchResult['count']) > 0){
echo ",";
echo "\"resultCount\":\"".$xml->paginationOutput->totalEntries."\",";
echo "\"pageNumber\":\"".$xml->paginationOutput->pageNumber."\",";
echo "\"itemCount\":\"".$xml->paginationOutput->entriesPerPage."\",";
$count = intval( $xml->searchResult['count']);
for ($i=0 ; $i< $count; ++$i) {
$item = $xml->searchResult->item[$i];
echo "\"item".$i."\" : {";
echo "\"basicInfo\" : {";
echo "\"title\":\"".urlencode($item->title)."\",";
echo "\"viewItemURL\":\"".urlencode($item->viewItemURL)."\",";
echo "\"galleryURL\":\"".urlencode($item->galleryURL)."\",";
echo "\"pictureURLSuperSize\":\"".urlencode($item->pictureURLSuperSize)."\",";
echo "\"convertedCurrentPrice\":\"".$item->sellingStatus->convertedCurrentPrice."\",";
echo "\"shippingServiceCost\":\"".$item->shippingInfo->shippingServiceCost."\",";
echo "\"conditionDisplayName\":\"".$item->condition->conditionDisplayName."\",";
echo "\"listingType\":\"".$item->listingInfo->listingType."\",";
echo "\"location\":\"".$item->location."\",";
echo "\"categoryName\":\"".$item->primaryCategory->categoryName."\",";
echo "\"topRatedListing\":\"".$item->topRatedListing."\"";
echo "},";
echo "\"sellerInfo\" : {";
echo "\"sellerUserName\":\"".$item->sellerInfo->sellerUserName."\",";
echo "\"feedbackScore\":\"".$item->sellerInfo->feedbackScore."\",";
echo "\"positiveFeedbackPercent\":\"".$item->sellerInfo->positiveFeedbackPercent."\",";
echo "\"feedbackRatingStar\":\"".$item->sellerInfo->feedbackRatingStar."\",";
echo "\"topRatedSeller\":\"".$item->sellerInfo->topRatedSeller."\",";
echo "\"sellerStoreName\":\"".$item->storeInfo->storeName."\",";
echo "\"sellerStoreURL\":\"".$item->storeInfo->storeURL."\"";
echo "}," ;
echo "\"shippingInfo\" : {";
echo "\"shippingType\":\"".$item->shippingInfo->shippingType."\",";
if ( is_array($item->shippingInfo->shipToLocations)){
echo "\"shipToLocations\":";
$length = count($item->shippingInfo->shipToLocations);
for ($j = 0; $j < $length; ++$j) {
echo $item->shippingInfo->shipToLocations[$j];
if(($j + 1)!= $length)
echo ",";
}
echo ",";
}else{
echo "\"shipToLocations\":\"".$item->shippingInfo->shipToLocations."\",";
}
echo "\"expeditedShipping\":\"".$item->shippingInfo->expeditedShipping."\",";
echo "\"oneDayShippingAvailable\":\"".$item->shippingInfo->oneDayShippingAvailable."\",";
echo "\"returnsAccepted\":\"".$item->shippingInfo->returnsAccepted."\",";
echo "\"handlingTime\":\"".$item->shippingInfo->handlingTime."\"";
echo "}" ;
echo "}";
if(($i + 1) != $count)
echo ",";
}
}
echo "}";
?>