-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample_usage.php
154 lines (127 loc) · 4.49 KB
/
sample_usage.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
<?php
/* ************************************************************************************************
/$$$$$$ /$$ /$$ /$$$$$$$$
/$$__ $$ | $$ | $$ |_____ $$
| $$ \ $$ /$$$$$$$ | $$ /$$ /$$$$$$ | $$ /$$/ /$$$$$$ /$$$$$$ /$$$$$$/$$$$
| $$ | $$| $$__ $$| $$ /$$/ /$$__ $$| $$ /$$/ /$$__ $$ /$$__ $$| $$_ $$_ $$
| $$ | $$| $$ \ $$| $$$$$$/ | $$$$$$$$| $$ /$$/ | $$ \ $$| $$ \ $$| $$ \ $$ \ $$
| $$ | $$| $$ | $$| $$_ $$ | $$_____/| $$ /$$/ | $$ | $$| $$ | $$| $$ | $$ | $$
| $$$$$$/| $$ | $$| $$ \ $$| $$$$$$$| $$ /$$$$$$$$| $$$$$$/| $$$$$$/| $$ | $$ | $$
\______/ |__/ |__/|__/ \__/ \_______/|__/ |________/ \______/ \______/ |__/ |__/ |__/
Description:
PHP Usage Example (v.1.0)
Copyright:
Zoom Social Commerce GmbH
Stanlay Forker <[email protected]>
http://www.onkel-zoom.com
************************************************************************************************ */
// INCLUDE THE REQUIRED ONKELZOOM API CLASS HELPER
require("OnkelZoom.class.php");
// DEFINE YOU AUTH INFO
define("ZOOM_API_MAIL", "__MY_ZOOM_API_MAIL__");
define("ZOOM_API_KEY", "__MY_ZOOM_API_KEY__");
// INITIATE THE API CLASS
$OnkelZoom = new OnkelZoom(ZOOM_API_MAIL, ZOOM_API_KEY);
// BUILD THE REQUEST PARAMS
# Get you Account Infos
$request_get_account_info = array(
"SERVICE" => "Account/Get"
);
# Update Offer by EAN
$request_update_offer = array(
"SERVICE" => "Offer/Update",
"DATA" => array(
"PRODUCT_EAN" => "000000000000000",
"PRODUCT_PRICE" => "12.34",
"PRODUCT_LINK" => "http://www.shop.com/product-deeplink.html",
"DELIVERY_VALUE" => "Lieferbar innerhalb 1-2 Tage",
"DELIVERY_PRICE" => "4.90",
"AVAILABLE" => "1"
)
);
# Get Offer by EAN
$request_get_offer = array(
"SERVICE" => "Offer/Get",
"DATA" => array(
"PRODUCT_EAN" => "000000000000000"
)
);
# Get all Offers
$request_get_all_offer = array(
"SERVICE" => "Offer/Get/All",
"DATA" => array(
"START" => "0",
"LIMIT" => "10",
"ORDER_BY" => "DATE_MOD",
"ORDER_DESC" => "DESC"
)
);
# Add new Offer
$request_add_offer = array(
"SERVICE" => "Offer/Add",
"DATA" => array(
"PRODUCT_EAN" => "",
"PRODUCT_PRICE" => "12.34",
"PRODUCT_PRICE_OLD" => "43.21",
"PRODUCT_AVAILABLE" => "1",
"PRODUCT_LINK" => "http://www.shop.com/product-deeplink.html",
"DELIVERY_VALUE" => "Lieferbar innerhalb 1-2 Tage",
"DELIVERY_PRICE" => "4.90",
"TOKEN" => ""
)
);
# BUILD THE MD5 HASH TOKEN
$request_add_offer["DATA"]["TOKEN"] = md5(
$request_add_offer["DATA"]["PRODUCT_EAN"] .
$request_add_offer["DATA"]["PRODUCT_PRICE"] .
$request_add_offer["DATA"]["PRODUCT_PRICE_OLD"] .
$request_add_offer["DATA"]["PRODUCT_AVAILABLE"] .
$request_add_offer["DATA"]["PRODUCT_LINK"] .
$request_add_offer["DATA"]["DELIVERY_VALUE"] .
$request_add_offer["DATA"]["DELIVERY_PRICE"] .
strrev(ZOOM_API_KEY)
);
// RUN THE REQUEST TO ONKEL ZOOM
echo "SERVICE TEST: Account/Get<br>";
$api_response = $OnkelZoom->request($request_get_account_info);
handle_api_response($api_response);
echo "<hr>SERVICE TEST: Offer/Update<br>";
$api_response = $OnkelZoom->request($request_update_offer);
handle_api_response($api_response);
echo "<hr>SERVICE TEST: Offer/Get<br>";
$api_response = $OnkelZoom->request($request_get_offer);
handle_api_response($api_response);
echo "<hr>SERVICE TEST: Offer/Get/All<br>";
$api_response = $OnkelZoom->request($request_get_all_offer);
handle_api_response($api_response);
echo "<hr>SERVICE TEST: Offer/Add<br>";
$api_response = $OnkelZoom->request($request_add_offer);
handle_api_response($api_response);
// HANDLE THE SERVER RESPONSE
function handle_api_response($api_response){
switch($api_response["STATUS"]){
case "200": {
echo "Request successfully<br>";
echo "<pre>Server-Response:<br>"; print_r($api_response); echo "</pre>";
break;
}
case "403":
case "404":
case "405": {
echo "Something went wrong with Authentification<br>";
echo "<pre>Server-Response:<br>"; print_r($api_response); echo "</pre>";
break;
}
case "501":
case "503":
case "505":
case "506":
case "507":
case "508": {
echo "Something went wrong with Service-Request<br>";
echo "<pre>Server-Response:<br>"; print_r($api_response); echo "</pre>";
break;
}
}
}
?>