forked from magento/devdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathht_extend_magento_rest_api.html
649 lines (599 loc) · 46 KB
/
ht_extend_magento_rest_api.html
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
---
---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="{{ site.baseurl }}common/css/stylesheet.css"/>
<link rel="stylesheet" href="{{ site.baseurl }}common/css/stylesheet-fonts.css" type="text/css" charset="utf-8">
<link rel="icon" href="{{ site.baseurl }}common/css/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="{{ site.baseurl }}common/css/favicon.ico" type="image/x-icon">
</head>
<title>How to Extend the Magento REST API to Use Coupon Auto Generation</title>
<!-- how-to-use-extend-the-magento-rest-api-to-use-coupon-auto-generation -->
<!-- Begin Content -->
<body>
<a name="top"></a>
<img src="{{ site.baseurl }}common/images/m1x/m1xheader.png" width="1024" alt="header" />
<h1>How to Extend the Magento REST API to Use Coupon Auto Generation</h1>
<h4>Table of Contents</h4>
<ul>
<li><a href="#overview">Overview</a></li>
<li><a href="#system-reqs">System Requirements</a></li>
<li><a href="#define-coupon-codes">Generating Coupon Codes</a></li>
<li><a href="#extend-rest-api">Extending Magento's REST API to Include Coupon Auto-Generation</a></li>
<li><a href="#secure">Securing the Coupon AutoGen API</a></li>
<li><a href="#test">Testing the Coupon AutoGen API</a></li>
<li><a href="#trouble">Troubleshooting Suggestions</a></li>
<li><a href="#next">Next Steps</a></li>
</ul>
<h2 id="overview">Overview</h2>
<p>Customers of traditional stores and online web stores love coupons. Typically, a merchant sends coupons to customers who input them when checking out. The coupon saves the customer money and hopefully entices the customer to visit the store more frequently. In addition, the merchant can track coupon codes to individual customers to target market those customers.</p>
<h3 id="overview-general">Coupon Auto Generation and the Magento REST API</h3>
<p>Magento CE 1.7 introduced a new method of creating coupon codes—<em>auto generation</em>. Auto generating coupons means Magento programmatically creates several coupon codes at one time quickly and easily. However, if Magento generates the coupon codes, you'd have to manually distribute them to customers.</p>
<p>Magento's REST API is extensible and can easily be called by an outside program to auto generate coupon codes. You can use this feature, for example, to e-mail coupon codes to your top 100 customers.</p>
<p>No programming is necessary to implement the extension module discussed in this guide; however, basic familiarity with <a href="http://www.magentocommerce.com/magento-connect/create_your_extension/" target="_blank">Magento modules</a> and PHP programming is desirable.</p>
<p>The Coupon AutoGen API enables any authorized external program to instruct Magento to:</p>
<ul><li>Auto-generate the specified number of coupon codes</li>
<li>Return these codes to the calling program—simulated in this guide using a simple <code>.php</code> file</li></ul>
<h3 id="overview-detail">Implementation Details</h3>
<p>This guide discusses how to use coupon auto generation and a web service to dynamically call the Magento REST API to generate a series of codes. The web service instantiates the underlying Magento sales rule (<code>salesrule/rule</code>) coupon code generator and creates a pool of new codes. These codes returned to the caller as a JSON string.</p>
<p>For more information about the Magento REST API, see <a href="http://www.magentocommerce.com/api/rest/introduction.html" target="_blank">Introduction to REST API</a>. To extend the REST API to add a web service for generating and retrieving coupon codes, this guide discusses the following:</p>
<ul><li>Setting up an auto generated coupon rule</li>
<li>Creating a module to use a REST based API extension<br />
This guide gives you all the files to create the module; no programming is necessary. There are four module configuration <code>.xml</code> files and one <code>.php</code> file to create the web service.</li>
<li>Creating a user for the OAuth access to the new service</li>
<li>Testing the web service from a separate page</li></ul>
<h2 id="system-reqs">System Requirements</h2>
<p>To implement and test the Coupon AutoGen API, you must have all of the following:</p>
<ul><li>Magento Community Edition (CE) 1.7 or later on Ubuntu.</li>
<li>Magento Enterprise Edition (EE) 1.12 or later on Ubuntu.</li>
<li><a href="http://pecl.php.net/package/oauth" target="_blank">pecl OAuth 1.0a extension</a> which you install as discussed in <a href="#prereq-software">Installing OAuth</a>.<br />
Magento CE 1.7 and later support the <a href="http://tools.ietf.org/html/rfc5849" target="_blank">OAuth 1.0a specification</a>.</li>
<li><em>Optional.</em> <a href="http://www.phpmyadmin.net/home_page/downloads.php" target="_blank"><code>phpmyadmin</code></a>, which makes it easier to view and manipulate the Magento database. You can use <code>phpmyadmin</code> for convenience to get the OAuth key and shared secret later in this guide.</li>
</ul>
<div class="msg-box important"><img src="{{ site.baseurl }}common/images/m1x/icon-note.png" alt="note" align="left" width="40"><span><strong>Note</strong>: Although Magento supports other Linux operating systems, Ubuntu is the only one discussed in this guide. Consult an appropriate reference for equivalent commands on other Linux operating systems.</div>
<h3 id="prereq-software">Installing OAuth</h3>
<p>This section discusses how to install the <a href="http://pecl.php.net/package/oauth" target="_blank">pecl OAuth extension</a> on Ubuntu. Consult the <a href="http://pecl.php.net/support.php" target="_blank">pecl.php.net documentation</a> for installation instructions on other operating systems.</p>
<p>The pecl OAuth extension requires the PEAR installer. The following sections discuss the installation in detail:</p>
<ul><li><a href="#prereq-software-phpinfo">Creating a phpinfo File</a></li>
<li><a href="#prereq-software-pear">Installing the OAuth Packages</a></li>
<li><a href="#prereq-software-oauth">Confirming that OAuth Installed Successfully</a></li></ul>
<div class="msg-box important"><img src="{{ site.baseurl }}common/images/m1x/icon-note.png" alt="note" align="left" width="40"><span><strong>Note</strong>: You must perform the tasks discussed in this section as a user with <code>root</code> privileges.</div>
<h4 id="prereq-software-phpinfo">Creating a phpinfo File</h4>
<p>Before you begin, create a <code>phpinfo.php</code> file, if you have not already done so, to determine if you already have OAuth running.</p>
<p>To create <code>phpinfo.php</code>:</p>
<ol><li>Open a command prompt window and connect to your Magento server.</li>
<li>Create a file named <code>phpinfo.php</code> anywhere on the web server's docroot:
<pre><?php
// Show all information, defaults to INFO_ALL
phpinfo();</pre></li>
<li>Start a web browser and enter the following URL in its address or location field:
<pre>http://<em>host-or-ip</em>[:<em>port</em>]/<em>path-to-phpinfo</em>/phpinfo.php</pre><br />
For example, if your Magento instance host name is <code>www.example.com</code> and you put <code>phpinfo.php</code> in the web server's docroot, enter:
<pre>http://www.example.com/phpinfo.php</pre></li>
<li>Search the resulting output for <code>OAuth</code>.<br />
The following figure shows an example of OAuth being properly set up.<br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_phpinfo-oauth.png"><br />
If the preceding does <em>not</em> display, OAuth is not set up so continue with the next section.<br />
If OAuth is already installed, continue with <a href="#define-coupon-rule">Defining a Magento Coupon Code Generation Rule</a>.</li></ol>
<h4 id="prereq-software-pear">Installing the OAuth Packages</h4>
<p>The pecl OAuth extension requires both PEAR (which enables you to install the package) and <code>libpcre3-dev</code>, which enables the OAuth package to be compiled.</p>
<p>To install the packages and confirm that OAuth is enabled:</p>
<ol><li>Enter the following commands in the order shown:
<pre>apt-get install php-pear
apt-get install libpcre3-dev
pecl install oauth</pre><br />
<div class="msg-box important"><img src="{{ site.baseurl }}common/images/m1x/icon-note.png" alt="note" align="left" width="40"><span><strong>Note</strong>: Remember that you must perform the tasks discussed in this section as a user with <code>root</code> privileges.</div>
<p>Wait while each package is installed. The message <code>Build process completed successfully</code> displays to indicate OAuth installed successfully.<br />
<div class="msg-box important"><img src="{{ site.baseurl }}common/images/m1x/icon-note.png" alt="note" align="left" width="40"><span><strong>Note</strong>: If <code>Error: `make' failed</code> displays after you enter <code>pecl install oauth</code>, see <a href="#trouble-oauth">OAuth Package Installation Error: `make' failed</a>.</div>
If the following displays, you must edit your <code>php.ini</code> file to find the OAuth library:
<pre>configuration option "php_ini" is not set to php.ini location
You should add "extension=oauth.so" to php.ini</pre></li>
<li>Open <code>php.ini</code> in a text editor.<br />
If you're not sure where it's located look in the <code>phpinfo.php</code> page output.
Add the following anywhere in <code>php.ini</code>:
<pre>[OAuth]
extension=oauth.so</pre></li>
<li>Save your changes to <code>php.ini</code> and exit the text editor.</li>
<li>Enter the following command to restart the Apache web server.
<pre>service apache2 restart</pre></li>
<li>Continue with the next section.</li></ol>
<h4 id="prereq-software-oauth">Confirming that OAuth Installed Successfully</h4>
<p>If your <code>phpinfo.php</code> page is still open in a web browser, press Control+R to force a refresh; otherwise, enter the URL shown in <a href="#prereq-software-phpinfo">Creating a phpinfo File</a> to view it.</p>
<p>The following figure shows an example of a properly set up OAuth extension.</p>
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_phpinfo-oauth.png">
<div class="msg-box important"><img src="{{ site.baseurl }}common/images/m1x/icon-note.png" alt="note" align="left" width="40"><span><strong>Note</strong>: Do not continue until you know that OAuth installed successfully.</div>
<h2 id="define-coupon-rule">Defining a Magento Coupon Code Generation Rule</h2>
<p>To define a Magento coupon code generation rule:</p>
<ol><li>Log in to the Magento Admin Panel as an administrator.</li>
<li>Click <strong>Promotions</strong> > <strong>Shopping Cart Price Rules</strong>.</li>
<li>On the Shopping Cart Price Rules page, click <strong>Add New Rule</strong> (in the upper-right corner of the page).<br />
The General Information page displays as follows.<br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_rest_rule_info.png"></li>
<li>Enter the following information.<br />
<table>
<tbody>
<tr class="table-headings">
<col width="200">
<col width="300">
<th>Item</th>
<th>Description</th>
<tbody>
</tr>
<tr>
<td>Rule Name</td>
<td>Enter <code>Generate Coupons</code>.</td>
</tr>
<tr>
<td>Description</td>
<td>Enter an optional description of the rule, such as <code>Rule that generates a sequence of coupon codes</code>.</td>
</tr>
<tr>
<td>Status</td>
<td>From the list, click <strong>Active</strong>.</td>
</tr>
<tr>
<td>Websites</td>
<td>Click the web sites on which you want the coupons to display. Hold down the Shift key and click the names of all items to select them.</td>
</tr>
<tr>
<td>Customer Groups</td>
<td>Hold down the Shift key and click the names of all items to select them.</td>
</tr>
<tr>
<td>Coupon</td>
<td>Click <strong>Specific Coupon</strong></td>
</tr>
<tr>
<td>Coupon Code</td>
<td>Leave the field blank.</td>
</tr>
<tr>
<td><em>CE only</em>. Auto Generation</td>
<td>Select the <strong>Use Auto Generation</strong> check box. </td>
</tr>
<tr>
<td><em>CE only</em>. Uses per Coupon</td>
<td>Enter <code>10</code>.</td>
</tr>
<tr>
<td>Uses per Customer</td>
<td>Enter <code>1</code>.</td>
</tr>
<tr>
<td>From Date</td>
<td>Select today's date.</td>
</tr>
<tr>
<td>To Date</td>
<td>Select any date in the future.</td>
</tr>
<tr>
<td>Priority</td>
<td>Enter <code>0</code>.</td>
</tr>
<tr>
<td>Public In RSS Feed</td>
<td>Click <strong>No</strong>.</td>
</tr>
</tbody>
</table></li>
<li>In the upper-right corner of the page, click <strong>Save and Continue Edit</strong>.<br />
The message <code>The rule has been saved</code> displays at the top of the page to indicate that Magento successfully saved the rule you just created.</li>
<li>In the left navigation bar, click <strong>Actions</strong>.<br />
The Actions page displays as follows.<br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_rest_rule_actions.png" height="303px" width="600px"></li>
<li>Enter the following information.<br />
<table>
<tbody>
<tr class="table-headings">
<th>Item</th>
<th>Description</th>
</tr>
<tr>
<td>Apply</td>
<td>From the list, click <strong>Percent of product price discount</strong>.</td>
</tr>
<tr>
<td>Discount Amount</td>
<td>Enter <code>10</code>.</td>
</tr>
<tr>
<td>Maximum Qty Discount is Applied To</td>
<td>Enter <code>1</code>.</td>
</tr>
<tr>
<td>Discount Qty Step (Buy X)</td>
<td>Enter <code>1</code>.</td>
</tr>
<tr>
<td>Apply to Shipping Amount</td>
<td>From the list, click <strong>No</strong>.</td>
</tr>
<tr>
<td>Free Shipping</td>
<td>From the list, click <strong>No</strong>.</td>
</tr>
<tr>
<td>Stop Further Rules Processing</td>
<td>From the list, click <strong>Yes</strong>.</td>
</tr>
<tr>
<td><em>EE only</em> Add Reward Points</td>
<td>Enter <code>0</code>.</td>
</tr>
</tbody>
</table></li>
<li>Click <strong>Save</strong> (in the upper-right corner of the page).<br />
The message <code>The rule has been saved</code> displays to indicate that Magento saved the rule action options you just entered. Notice that this page now has a row for the Generate Coupons rule you just defined.<br />
A sample follows.<br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_shopping_cart_price_rule.png" height="120px" width="600px"></li>
<li>Write down the rule ID (circled in red in the preceding figure). You will use this value later in this guide.</li></ol>
<h2><a name="define-coupon-codes"></a>Generating Coupon Codes</h2>
<p>Now that you've created a rule, this section discusses how to use the rule to manually generate a sequence of coupon codes.</p>
<ol><li>In the Shopping Cart Price Rules page, click the name of the rule you just created (<strong>Generate Coupons</strong>).</li>
<li>In the left navigation bar, click <strong>Manage Coupon Codes</strong>.</li>
<li>On the Coupons Information page, enter the following information:<br />
<table>
<tbody>
<tr class="table-headings">
<th>Item</th>
<th>Description</th>
</tr>
<tr>
<td>Coupon Qty</td>
<td>Enter <code>3</code>.</td>
</tr>
<tr>
<td>Code Length</td>
<td>Enter <code>12</code>.</td>
</tr>
<tr>
<td>Code Format</td>
<td>Click <strong>Alphanumeric</strong>.</td>
</tr>
<tr>
<td>Coupon Prefix</td>
<td>Enter <code>TEST-</code>.</td>
</tr>
<tr>
<td>Coupon Suffix</td>
<td>Enter <code>-TEST</code>.</td>
</tr>
<tr>
<td>Dash Every X Characters</td>
<td>Enter <code>0</strong>.</td>
</tr>
</tbody>
</table></li>
<li>Click <strong>Generate</strong>.<br />
Magento displays the three coupon codes you created in the Coupon Code section as the following figure shows. <br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_manage_coupon_codes.png" height="366px" width="600px"></li>
<li>Click <strong>Save</strong>.</li></ol>
<h2 id="extend-rest-api">Extending Magento's REST API to Include Coupon Auto-Generation</h2>
<p>In the preceding section, you created a Shopping Cart Price Rule named Generate Coupons that manually generates a set of coupon codes. To use those codes, you could export them to a file, and then import them into any external program you want; however, this is a time-consuming procedure!</p>
<p>Fortunately, you can automate this process by adding a <em>coupon code auto-generate</em> API to Magento's existing REST API. Using this API, an external program can automatically get the coupon codes it needs.</p>
<p>The following sections discuss how to extend Magento's REST API to include the Coupon AutoGen API:</p>
<ul><li><a href="#extend-rest-api_disable-cache">Disabling the Magento Cache</a></li>
<li><a href="#extend-rest-api_create-files">Creating Configuration Files</a></li>
<li><a href="#extend-rest-api_permissions">Setting Permissions on the Configuration Files</a></li></ul>
<h3><a name="extend-rest-api_disable-cache"></a>Disabling the Magento Cache</h3>
<p>While you're implementing the Coupon AutoGen API, you must disable Magento's caching so Magento will find and use your new code immediately.</p>
<p>To disable the cache:</p>
<ol><li>In the Magento Admin Panel, click <strong>System</strong> > <strong>Cache Management</strong>.<br />
The Cache Storage Management page displays as follows.<br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_disable-cache-magement.png" height="133px" width="600px"></li>
<li>Click <strong>Select All</strong> (on the upper-left of the page).<br />
A check mark displays next to each Magento cache in the list.</li>
<li>From the <strong>Actions</strong> list, click <strong>Disable</strong>.</li>
<li>Click <strong>Submit</strong>.<br />
Magento disables the selected caches, replacing the green ENABLED status indicators with red DISABLED indicators.</li>
<li>Click <strong>Flush Magento Cache</strong> and wait for the cache to be flushed.</li>
<li>Log out of the Magento Admin Panel.</li></ol>
<h3><a name="extend-rest-api_create-files"></a>Creating Configuration Files</h3>
<p>This section discusses how to create a module (also referred to as an <em>extension</em>). The module consists of configuration files that create a web service that extends the Magento REST API to take input from an external program. This program uses <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5" target="_blank">HTTP POST</a> and OAuth calls to auto-generate coupon codes.</p>
<p>In this guide, the external program is a PHP script; however, it could be any application that uses OAuth and REST calls. </p>
<p>For more information about Magento module development, see <a href="http://www.magentocommerce.com/magento-connect/create_your_extension/" target="_blank">developer documentation on Magento Connect</a>.</p>
<div class="msg-box important"><img src="{{ site.baseurl }}common/images/m1x/icon-note.png" alt="note" align="left" width="40"><span><strong>Note</strong>: It is up to you to determine ownership and permissions. This guide assumes you create files and directories as <code>root</code> and change the permissions appropriately later. Consult an IT administrator if you're not sure how to proceed.</div>
<ol><li>Log in to your Magento server and create the following directories:
<pre>
<em>magento-install-dir</em>/app/code/community/CouponDemo
<em>magento-install-dir</em>/app/code/community/CouponDemo/AutoGen
<em>magento-install-dir</em>/app/code/community/CouponDemo/AutoGen/etc
<em>magento-install-dir</em>/app/code/community/CouponDemo/AutoGen/Model
<em>magento-install-dir</em>/app/code/community/CouponDemo/AutoGen/Model/Api2
<em>magento-install-dir</em>/app/code/community/CouponDemo/AutoGen/Model/Api2/Coupon
<em>magento-install-dir</em>/app/code/community/CouponDemo/AutoGen/Model/Api2/Coupon/Rest
<em>magento-install-dir</em>/app/code/community/CouponDemo/AutoGen/Model/Api2/Coupon/Rest/Admin</pre>
For example, if Magento is installed in <code>/var/www/magento</code>, create the following directories:
<pre>
/var/www/magento/app/code/community/CouponDemo
/var/www/magento/app/code/community/CouponDemo/AutoGen/etc
/var/www/magento/app/code/community/CouponDemo/AutoGen/Model/Api2/Coupon/Rest/Admin</pre><br />
<p id="figure_dir-structure">The following figure shows an example.</p>
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_dir-structure.png"><br />
<div class="msg-box important"><img src="{{ site.baseurl }}common/images/m1x/icon-important.png" alt="important" align="left" width="40"><span><strong>Important</strong>: <ul><li>You must create the files and directories <em>exactly</em> as shown; directory names are case-sensitive.</li>
<li>Do not change any values in the configuration files discussed in this section.</li>
<li>When you create your configuration files, leave <em>no white space</em> at the beginning of the files. Leading white space might cause errors when Magento reads the files and might prevent the coupon demonstration module from working.</li></ul></span></div>
</p>
</li>
<!-- <li>Create the files listed below.<br />
Note that <code><em>magentoInstallDir</em></code> is a placeholder for the directory containing your Magento installation. <br />
<ul>
<li><code><em>magentoInstallDir</em>/app/etc/modules/CouponDemo_AutoGen.xml</code></li>
<li><code><em>magentoInstallDir</em>/app/code/community/CouponDemo/AutoGen/etc/config.xml</code></li>
<li><code><em>magentoInstallDir</em>/app/code/community/CouponDemo/AutoGen/etc/api.xml</code></li>
<li><code><em>magentoInstallDir</em>/app/code/community/CouponDemo/AutoGen/etc/api2.xml</code></li>
<li><code><em>magentoInstallDir</em>/app/code/community/CouponDemo/AutoGen/Model/Catalog/Api2/Product/Rest/Admin/V1.php</code></li>
</ul>
<strong>NOTE:</strong> For each file listed above, you must create the <em>exact</em> path shown. You must not change the name of any directory or file to something you prefer. Further, you must not change the case of any character in the directory or file names shown. If you do, your REST API extension won't work!</li> -->
<li>Change to the <code><em>magento-install-dir</em>/app/etc/modules</code> directory.</li>
<li id="trouble_xml">In that directory, use a text editor to create your module declaration file. This file must be named <code>CouponDemo_AutoGen.xml</code> and have the following contents.<br />
<script src="https://gist.github.com/4081239.js?file=CouponDemo_AutoGen.xml"></script></li>
<li>Save your changes to <code>CouponDemo_AutoGen.xml</code> and exit the text editor.</li>
<li>Change to the <code><em>magento-install-dir</em>/app/code/community/CouponDemo/AutoGen/etc</code> directory.</li>
<li>Create a file named <code>config.xml</code> with the following contents.<br />
<script src="https://gist.github.com/4089502.js?file=config.xml"></script></li>
<!-- <li>Create a file named <code>api.xml</code> with the following contents.<br />
<script src="https://gist.github.com/4089538.js?file=api.xml"></script></li>
<li>Save your changes to <code>api.xml</code> and exit the text editor.</li> -->
<li>Create a file named <code>api2.xml</code> with the following contents.<br />
<script src="https://gist.github.com/xcomSteveJohnson/6a97c176c8ee5d76e0c4.js"></script></li>
<li>Save your changes to <code>api2.xml</code> and exit the text editor.</li>
<li>Change to the <code><em>magento-install-dir</em>/app/code/community/CouponDemo/AutoGen/Model/Api2</code> directory.</li>
<li>Create a file named <code>Coupon.php</code> with the following contents.<br />
<script src="https://gist.github.com/xcomSteveJohnson/4bfde04ed707610722ee.js"></script>
<li>Save your changes to <code>Coupon.php</code> and exit the text editor.</li>
<li>Change to the <code><em>magento-install-dir</em>/app/code/community/CouponDemo/AutoGen/Model/Api2/Coupon/Rest/Admin</code> directory.</li>
<li>Create a file named <code>V1.php</code> with the following contents.<br />
<script src="https://gist.github.com/xcomSteveJohnson/551bd796539069a7cf99.js"></script></li>
<li>Save your changes to <code>V1.php</code> and exit the text editor.</li></ol>
<h3 id="extend-rest-api_permissions">Setting Permissions on the Configuration Files</h3>
<p>File permissions and ownership are important for any Linux application. Magento provides general guidelines for permission and ownership although following them are not a requirement for this guide. The configuration files and directories can be owned by <code>root</code> or other users and it won't prevent the procedures discussed in this guide from completing successfully.</p>
<p>Consult your network administrator if you are not sure how to set file permissions and ownership. The procedure that follows is a suggestion only.</p>
<p>The Magento guidelines discussed in the following procedure are taken from this Magento Wiki article and set the following:</p>
<ul><li>File and directory ownership set to <code><em>your-login-name</em>:<em>apache-user-group</em></code>.<br />
If you're not sure which group owns Apache processes, enter the command <code>ps -ef | grep apache2</code>. The following procedure assumes it is <code>www-data</code>.</li>
<li>File permissions set to 644.</li>
<li>Directory permissions set to 755.</li></ul>
<p>To optionally set permissions and ownership according to Magento guidelines:</p>
<ol><li>As a user with <code>root</code> privileges, enter the following commands in the order shown to change ownership of the files and directories you created as discussed in this guide:<br />
<pre>cd <em>magento-install-dir</em>/app/code/community
chown -R <em>your-login-name</em>:www-data CouponDemo
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;</pre></li>
<li>As a user with <code>root</code> privileges, enter the following commands in the order shown to change the permissions and ownership of <code>CouponDemo_AutoGen.xml</code><br />.
<pre>cd <em>magento-install-dir</em>/app/etc/modules
chown <em>your-login-name</em>:www-data CouponDemo_AutoGen.xml
chmod 644 CouponDemo_AutoGen.xml</pre></li></ol>
<h2 id="secure">Securing the Coupon AutoGen API</h2>
<p>For security reasons, Magento allows only authorized external programs to call the Magento REST API.</p>
<p>The following sections discuss how to enable the test script (discussed in the next section) to call the Coupon AutoGen API:</p>
<ul><li><a href="#secure-role">Creating a REST role for the Coupon AutoGen API</a></li>
<li><a href="#secure-role-users">Adding Users to the Coupon Auto Generate Demo Role</a></li>
<li><a href="#secure-role-attribs">Setting up REST Attributes for the Coupon AutoGen API</a></li>
<li><a href="#secure-role-oauth">Creating an OAuth Consumer for Your Test Script</a></li></ul>
<h3 id="secure-role">Creating a REST role for the Coupon AutoGen API</h3>
<p>To use the Magento Admin Panel to create a role for the Coupon AutoGen API:</p>
<ol><li>Log in to the Magento Admin Panel as an administrator.</li>
<li>Click <strong>System</strong> > <strong>Web Services</strong> > <strong>REST - Roles</strong>.</li>
<li>On the REST—Roles page, click <strong>Add Admin Role</strong>.</li>
<li>In the <strong>Role Name</strong> field, enter <code>Coupon Auto Generate Demo</code>.</li>
<li>Click <strong>Save Role</strong>.</li>
<li>In the left navigation bar, click <strong>Role API Resources</strong>.<br />
The Role Resources page contains a hierarchical list of resources to which you can grant or deny the Coupon Auto Generate Demo role access.</li>
<li>From the <strong>Resource Access</strong> list, click <strong>Custom</strong>.</li>
<li><p>Select the check box next to the node labeled <strong>CouponDemo API</strong>.</p>
<p id="figure_check-boxes">Magento automatically checks the child check boxes as the following figure shows.</p>
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_edit_rest_role_api_resources.png" height="203px" width="600px"></li>
<li>Click <strong>Save Role</strong>.<br />
Magento saves the resource API permissions you granted to the Coupon Auto Generate Demo REST role. <br />
The Coupon Auto Generate Demo role now has permission to use the Coupon AutoGen API.</li></ol>
<h3 id="secure-role-users">Adding Users to the Coupon Auto Generate Demo Role</h3>
<p>Now that you have a role, you must add users to give them permission to call the Coupon AutoGen API as follows:</p>
<ol><li>In the left navigation bar, click <strong>Role Users</strong>.</li>
<li>Click <strong>Reset Filter</strong> (in the upper-right corner of the page).<br />
The page displays all registered users as the following figure shows.<br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_edit_rest_role_users.png" height="116px" width="600px"><br /></li>
<li>Select the check box next to each user to grant the user privileges to access the resources available to the Coupon Auto Generate Demo REST role—that is, permission to call the Coupon AutoGen API.<br />
<div class="msg-box important"><img src="{{ site.baseurl }}common/images/m1x/icon-note.png" alt="note" align="left" width="40"><span><strong>Note</strong>: If a warning dialog box displays, click <strong>OK</strong> to dismiss it. This warning is not relevant when adding users to REST roles.</div>
</li>
<li>When you're done, click <strong>Save Role</strong>.<br />
The specified user(s) can now grant an external program the right to call the Coupon AutoGen API.</li></ol>
<h3 id="secure-role-attribs">Setting up REST Attributes for the Coupon AutoGen API</h3>
<p>This section discusses how to enable any user with a REST Admin role to use the Coupon AutoGen API.</p>
<p>To set REST attributes for the REST Admin role:</p>
<ol><li>Click <strong>System</strong> > <strong>Web Services</strong> > <strong>REST - Attributes</strong>.</li>
<li>On the REST Attributes page, under User Type, click <strong>Admin</strong>.</li>
<li>In the User Type Resources section, from the <strong>Resource Access</strong> list, click <strong>Custom</strong>.</li>
<li>Select the <strong>CouponDemo API</strong> check box.<br />
Doing so selects all the child check boxes, as the following figure shows.<br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_rest-api-attributes.png" height="263px" width="600px"></li>
<li>Click <strong>Save</strong>.<br />
Any user with the REST Admin role can now read from and write to the Coupon AutoGen API.</li></ol>
<h3 id="secure-role-oauth">Creating an OAuth Consumer for Your Test Script</h3>
<p>This section discusses how to create a consumer so you can test the Coupon AutoGen API before you deploy it in a production system. After successfully testing the API, you can remove this user.</p>
<ol><li>In the Magento Admin Panel, click <strong>System</strong> > <strong>Web Services</strong> > <strong>REST - OAuth Consumers</strong>.</li>
<li>Click <strong>Add New</strong> (in the upper-right corner of the page).<br />
The <strong>New Consumer</strong> page displays as the following figure shows.<br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_new_oauth_consumer.png" height="162px" width="600px"></li>
<li>In the <strong>Name</strong> field, enter <code>Coupon AutoGen Test Driver</code>.</li>
<li>Leave the other fields blank.</li>
<li><em>Write down</em> the values displayed in the <strong>Key</strong> and <strong>Secret</strong> text boxes. <br />
<div class="msg-box important"><img src="{{ site.baseurl }}common/images/m1x/icon-note.png" alt="note" align="left" width="40"><span><strong>Note</strong>: The key and secret values are stored in the Magento database in the table <code>oauth_consumer</code>. It might be more convenient for you to use <code>phpmyadmin</code> or database tools to retrieve them from the database after you save the role.</div>
You must include these values in the test script you will write in the next section. The script uses these values to identify itself to Magento.</li>
<li>Click <strong>Save</strong> (in the upper-right corner of the page).</li>
<li>Log out of the Magento Admin Panel.</li></ol>
<h2 id="test">Testing the Coupon AutoGen API</h2>
<p>This section discusses how to create a simple PHP file that acts as an external program and, with permissions you granted the OAuth consumer, enables the program to use the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5" target="_blank">HTTP POST</a> method to auto generate coupon codes.</p>
<p>You can use <em>any</em> type of OAuth/REST call, in fact, such as using the Firefox REST Client plug-in as discussed <a href="http://www.magentocommerce.com/api/rest/testing_rest_resources.html" target="_blank">here</a>.</p>
<p>The following sections discuss how to create and run the test script:</p>
<ul><li><a href="#test-create">Creating the Test Script</a></li>
<li><a href="#test-run">Running the Test Script</a></li></ul>
<h3 id="test-create">Creating the Test Script</h3>
<p>The test script you create calls the Coupon AutoGen API, thereby causing Magento to generate the specified coupon codes and return them to the caller (<code>rest_test.php</code>) in the form of a JSON-encoded string. Finally, the server responds to the browser's request with an HTML page containing the generated coupon codes.</p>
<p>The PHP code that follows:</p>
<ul><li>Uses your OAuth <code>consumerKey</code> and <code>consumerSecret</code> to set up the OAuth client.</li>
<li>Defines data to pass to the array <code>$couponGenerationData</code>. The data should include the following:
<ul><li>The rule ID (listed next to the rule in the rule list in the Magento Admin Panel)</li>
<li>The number of codes desired (in this case, two)</li>
<li>The length of the codes</li>
<li>The format to be used (in this case, alphanumeric)</li></ul>
</li>
<li>The array of parameters is then passed in the <code>fetch</code> command with the <code>resourceUrl</code> for the web service call.</li></ul>
<p> Finally, the server responds to the browser's request with an HTML page containing the generated coupon codes.</p>
<p>To create the test script, named <code>rest_test.php</code>:</p>
<ol><li>Create the file <code><em>magento-install-dir</em>/rest_test.php</code> with the following contents.
<script src="https://gist.github.com/4115482.js?file=rest_test.php"></script></li>
<li>The following table discusses the values you must change.
<table>
<tbody>
<tr class="table-headings">
<th>String to change</th>
<th>How to change it</th>
</tr>
<tr>
<td><<YOUR CONSUMER KEY>></td>
<td><p>Coupon AutoGen Test Driver OAuth consumer's key.</p>
<p>You can view this in the Admin Panel: <strong>System</strong> > <strong>Web Services</strong> > <strong>REST - OAuth Consumers</strong> or you can get the value from the <code>oauth_consumer</code> table in the Magento database.</p></td>
</tr>
<tr>
<td><<YOUR CONSUMER SECRET>></td>
<td><p>Coupon AutoGen Test Driver OAuth consumer's secret.</p>
<p>You can view this in the Admin Panel: <strong>System</strong> > <strong>Web Services</strong> > <strong>REST - OAuth Consumers</strong> or you can get the value from the <code>oauth_consumer</code> table in the Magento database.</p>
</td>
</tr>
<tr>
<td><<host-or-ip:port>>/<<path>></td>
<td><p>Your Magento instance's fully qualified host name or IP address and port, if you are using a port other than 80, and the path to your Magento installation. If you are running Magento on localhost, enter <code>127.0.0.1</p>
<p>For example, if your Magento server's host name is <code>www.example.com</code>, running on port 80, and Magento is installed at <code>/var/www/magento</code>, enter <code>http://www.example.com/magento</code></td>
</tr>
<tr>
<td><<RULE_ID>></td>
<td><p>Generate Coupons rule ID.</p>
<p>Get this value by clicking <strong>Promotions</strong> > <strong>Shopping Cart Price Rules</strong></p>.</td>
</tr>
</tbody>
</table>
<li>Save the file and close the text editor.</li></ol>
<h3 id="test-run">Running the Test Script</h3>
<p>To run the test script:</p>
<ol><li>Start a web browser.</li>
<li>In the browser's address or location field, enter:<br />
<pre>http://<em>magento-server-host-or-ip</em>[:<em>port</em>]/rest_test.php</pre></li>
<li>When prompted, enter the login credentials of the OAuth consumer you created as discussed in <a href="#secure-role-oauth">Creating an OAuth Consumer for Your Test Script</a>.</li>
<li>Click <strong>Login</strong>.</li>
<li>When prompted, click <strong>Authorize</strong> to grant authorization for the script to access your OAuth consumer account, as the following figure shows.<br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_oauth-request-access.png"></li>
<li>When prompted, log in as that user.<br />
After you log in, two new coupon codes display as follows to confirm you successfully used the API. If your browser displays a page like this one, you've successfully implemented the Coupon AutoGen REST API!<br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_new-coupon-codes.png"></li></ol>
<p>To optionally see these codes in the Admin Panel:</p>
<ol><li>Log in to the Admin Panel as an administrator.</li>
<li>Click <strong>Promotions</strong> > <strong>Shopping Cart Price Rules</strong>.</li>
<li>Click <strong>Generate Coupons</strong>.</li>
<li>In the left navigation bar, click <strong>Manage Coupon Codes</strong>.<br />
The codes you generated manually earlier display with the new codes (highlighted in red) as the following figure shows.<br />
<img src="{{ site.baseurl }}common/images/m1x/ht_magento-REST-API_verify_view-coupon-codesMock.png" height="331px" width="600px"></li></ol>
<h3 id="test-cache">Re-Enabling Magento's Cache</h3>
<p>Only after successfully completing the test, you should re-enable Magento's caching system, so performance returns to normal.<p>
<p>To re-enable the Magento cache:</p>
<ol><li>In the Magento Admin Panel, click <strong>System</strong> > <strong>Cache Management</strong>.</li>
<li>On the Cache Storage Management page, click <strong>Select All</strong> (in the upper-left of the page).<br />
A check mark displays next to each Magento cache in the list.</li>
<li>Click <code>Enable</code> from the <strong>Actions</strong> list.</li>
<li>Click <strong>Submit</strong>.<br />
Magento enables the selected caches. You can tell because the red DISABLED status indicator is replaced by a green ENABLED indicator.</li>
<li>Click <strong>Select All</strong> again.</li>
<li>Click <code>Refresh</code> from the <strong>Actions</strong> list.</li>
<li>Click <strong>Submit</strong>.<br />
Magento reloads the selected caches. Magento now performs much faster.</li></ol>
<p>Congratulations! You have successfully added the Coupon AutoGen API to Magento's REST API. Following the same procedure, you can expose lots of Magento functionality to external programs. </p>
<h2 id="trouble">Troubleshooting Suggestions</a></h2>
<p>The following sections discuss solutions to issues you might encounter when setting up this demonstration:</p>
<ul><li><a href="#trouble-oauth">OAuth Package Installation Error: `make' failed</a></li>
<li><a href="#trouble-admin-panel-options">CouponDemo API Calls Options Don't Display in the Admin Panel</a></li>
<li><a href="#trouble-rest-test">Errors Running rest_test.php</a></li></ul>
<h3 id="trouble-oauth">OAuth Package Installation Error: `make' failed</h3>
<p><strong>Problem:</strong> OAuth package installation fails with the error <code>ERROR: `make' failed</code>.</p>
<p><strong>Description:</strong> In some cases, the <code>pecl install oauth</code> command does not install a C compiler. If you encounter the following error, you must install the <code>make</code> package; otherwise, OAuth won't compile:</p>
<pre>1: make: not found
ERROR: `make' failed</pre>
<p><strong>Solution:</strong></p>
<ol><li>Enter the following commands in the order shown as a user with <code>root</code> privileges:</p>
<pre>apt-get install make
pecl install oauth</pre></li>
<li>Make sure the message <code>Build process completed successfully</code> displays to indicate OAuth compiled successfully.<br />
If the following displays, you must edit your <code>php.ini</code> file to find the OAuth library:
<pre>configuration option "php_ini" is not set to php.ini location
You should add "extension=oauth.so" to php.ini</pre></li>
<li>Open <code>php.ini</code> in a text editor.<br />
If you're not sure where it's located look in the <code>phpinfo.php</code> page output.
Add the following anywhere in <code>php.ini</code>:
<pre>[OAuth]
extension=oauth.so</pre></li>
<li>Save your changes to <code>php.ini</code> and exit the text editor.</li>
<li>Enter the following command to restart the Apache web server.
<pre>service apache2 restart</pre>
<li>Verify the OAuth installation succeeded as discussed in <a href="#prereq-software-oauth">Confirming that OAuth Installed Successfully</a>.</li></ol>
<h3 id="trouble-admin-panel-options">CouponDemo API Calls Options Don't Display in the Admin Panel</h3>
<p><strong>Problem:</strong> After setting up the CouponDemo configuration files, the <strong>CouponDemo API Calls</strong> check boxes do not display in the Admin Panel. A sample is shown <a href="#figure_check-boxes">in a figure earlier in this guide</a>.</p>
<p><strong>Description:</strong> The <strong>CouponDemo API Calls</strong> check boxes display to indicate you set up the module correctly. If they don't display, either the Magento cache hasn't been entirely cleared or there's something wrong with the directory structure or configuration files.</p>
<p><strong>Solution:</strong> Use the following steps to isolate and correct the issue:</p>
<ol><li>Make sure your directory structure is set up <em>exactly</em> as shown in <a href="#figure_dir-structure">this figure earlier in this guide</a>.</li>
<li>Make sure you copied the <em>exact text</em> from the sample configuration files discussed in <a href="#extend-rest-api_create-files">Creating Configuration Files</a>. <em>Do not change anything</em>, and remember that case is important.</li>
<li>Clear the Magento cache in all of the following ways:
<ul><li>As a user with sufficient privileges to delete files and directories in the Magento installation, enter the following commands:<br />
<pre>rm -r <em>magento-install-dir</em>/var/cache
rm -r <em>magento-install-dir</em>/var/session</pre></li>
<li>Log in to the Magento Admin Panel as an administrator and click <strong>System</strong> > <strong>Cache Management</strong>.<br />
Click <strong>Flush Magento Cache</strong>.<br />
Click <strong>Flush Cache Storage</strong> and follow the prompts on your screen to delete the cache storage.</li></ul>
</li>
<li>Log out of the Magento Admin Panel and log back in.</li>
<li>Click <strong>System</strong> > <strong>REST - Roles</strong>.</li>
<li>Click <strong>Coupon Auto Generate Demo</strong>.</li>
<li>In the left navigation bar, click <strong>Role API Resources</strong>.</li>
<li>If the <strong>CouponDemo API Calls</strong> check boxes do not display, double-check <a href="#trouble_xml">all of the <code>.xml</code> configuration files</a> to make sure there is <em>no leading white space</em> (that is, there are no blank lines at the beginning of the files.<br />
Remove any blank lines and save the <code>.xml</code> files.</li></ol>
<h3 id="trouble-rest-test">Errors Running rest_test.php</h3>
<p>The following sections discuss issues you might encounter when you run <code>rest_test.php</code> in a web browser:</p>
<ul><li><a href="#trouble-rest-test_consumer-key">Problem: Invalid auth/bad request</a></li>
<li><a href="#trouble-rest-test_rule-not-found">Invalid auth/bad request: Rule was not found</a></li>
<li><a href="#trouble-rest-test_rewrites">Invalid auth/bad request: /magento/oauth/initiate was not found on this server</a></li></ul>
<h4 id="trouble-rest-test_consumer-key">Invalid auth/bad request: oauth_problem=consumer_key_rejected</h4>
<p>The following error displays in the web browser:</p>
<pre>Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)
{"messages":{"error":[{"code":401,"message":"oauth_problem=consumer_key_rejected"}]}}</pre>
<p><strong>Description:</strong> Your OAuth authentication attempt failed because the credentials are incorrect.</p>
<p><strong>Solution:</strong> Open <code>rest_test.php</code> in a text editor and verify the values of the following:</p>
<pre>$consumerKey = '<em>value</em>';
$consumerSecret = '<em>value</em>';</pre>
<p>You can find these values in the <code>oauth_consumer</code> database table or in the Admin Panel: <strong>System</strong> > <strong>Web Services</strong> > <strong>REST - OAuth Consumers</strong>.</p>
<p>After verifying the correct values, save your changes to <code>rest_test.php</code> and try again.</p>
<h4 id="trouble-rest-test_rule-not-found">Invalid auth/bad request: Rule was not found</h4>
<p>The following error displays in the web browser:</p>
<pre>Invalid auth/bad request (got a 404, expected HTTP/1.1 20X or a redirect)
{"messages":{"error":[{"code":404,"message":"Rule was not found."}]}}</pre>
<p><strong>Description:</strong> The shopping cart promotion rule could not be found.</p>
<p><strong>Solution:</strong> Open <code>rest_test.php</code> in a text editor and verify the value of the following:</p>
<pre>$ruleId = <em>value</em>;</pre>
<p>You can find this value in the Admin Panel: <strong>Promotions</strong> > <strong>Shopping Cart Price Rules</strong>.</p>
<p>Change the value in <code>rest_test.php</code>, save it, and try again.</p>
<h4 id="trouble-rest-test_rewrites">Invalid auth/bad request: /magento/oauth/initiate was not found on this server</h4>
<p>The following error displays in the web browser:</p>
<pre>Invalid auth/bad request (got a 404, expected HTTP/1.1 20X or a redirect)
Not Found
The requested URL /magento/oauth/initiate was not found on this server.</pre>
<p><strong>Description:</strong> The HTTP redirect failed, most likely because web server rewrites are not properly enabled.</p>
<p><strong>Solution:</strong> Make sure web server rewrites are enabled. The procedure you use depends on your web server and operating system. An example for Ubuntu can be found <a href="http://www.fontis.com.au/blog/magento/definitive-installation-guide" target="_blank">here</a>.</p>
<h2 id="next">Next Steps</h2>
<p>Refer to <a href="http://www.magentocommerce.com/api/rest/introduction.html#RESTAPIIntroduction-Overview">Magento APIs—REST</a> for documentation explaining how the Magento's REST API framework works.</p>
<!-- </li>
<li>Refer to <a href="https://wiki.corp.x.com/display/MWSAPI/Documentation+REST+API">Documentation REST</a> for instructions explaining how to use the REST APIs included in Magento "out of the box".<br />
<a href="https://wiki.corp.x.com/display/MWSAPI/Documentation+REST+API"></a></li>
</ul> -->
<!-- End Content -->
</body>
</html>