-
Notifications
You must be signed in to change notification settings - Fork 10
/
pas.class.php
executable file
·1705 lines (1557 loc) · 134 KB
/
pas.class.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
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
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* File: Amazon PAS
* Product Advertising Service (http://aws.amazon.com/associates)
*
* Version:
* 2009.09.04
*
* Copyright:
* 2006-2009 Foleeo, Inc., and contributors.
*
* License:
* Simplified BSD License - http://opensource.org/licenses/bsd-license.php
*
* See Also:
* CloudFusion - http://getcloudfusion.com
* Amazon PAS - http://aws.amazon.com/associates
*/
/*%******************************************************************************************%*/
// CONSTANTS
/**
* Constant: PAS_LOCALE_US
* Locale code for the United States
*/
define('PAS_LOCALE_US', 'us');
/**
* Constant: PAS_LOCALE_UK
* Locale code for the United Kingdom
*/
define('PAS_LOCALE_UK', 'uk');
/**
* Constant: PAS_LOCALE_CANADA
* Locale code for Canada
*/
define('PAS_LOCALE_CANADA', 'ca');
/**
* Constant: PAS_LOCALE_FRANCE
* Locale code for France
*/
define('PAS_LOCALE_FRANCE', 'fr');
/**
* Constant: PAS_LOCALE_GERMANY
* Locale code for Germany
*/
define('PAS_LOCALE_GERMANY', 'de');
/**
* Constant: PAS_LOCALE_JAPAN
* Locale code for Japan
*/
define('PAS_LOCALE_JAPAN', 'jp');
/*%******************************************************************************************%*/
// EXCEPTIONS
/**
* Exception: PAS_Exception
* Default PAS Exception.
*/
class PAS_Exception extends Exception {}
/*%******************************************************************************************%*/
// MAIN CLASS
/**
* Class: AmazonPAS
* Container for all Amazon PAS-related methods. Inherits additional methods from CloudFusion.
*
* Extends:
* CloudFusion
*
* Example Usage:
* (start code)
* require_once('cloudfusion.class.php');
*
* // Instantiate a new AmazonPAS object using the settings from the config.inc.php file.
* $s3 = new AmazonPAS();
*
* // Instantiate a new AmazonPAS object using these specific settings.
* $s3 = new AmazonPAS($key, $secret_key, $assoc_id);
* (end)
*/
class AmazonPAS extends CloudFusion
{
/**
* Property: locale
* The Amazon locale to use by default.
*/
var $locale;
/*%******************************************************************************************%*/
// CONSTRUCTOR
/**
* Method: __construct()
* The constructor
*
* Access:
* public
*
* Parameters:
* key - _string_ (Optional) Your Amazon API Key. If blank, it will look for the <AWS_KEY> constant.
* secret_key - _string_ (Optional) Your Amazon API Secret Key. If blank, it will look for the <AWS_SECRET_KEY> constant.
* assoc_id - _string_ (Optional) Your Amazon Associates ID. If blank, it will look for the <AWS_ASSOC_ID> constant.
*
* Returns:
* _boolean_ false if no valid values are set, otherwise true.
*/
public function __construct($key = null, $secret_key = null, $assoc_id = null)
{
$this->api_version = '2009-07-01';
if (!$key && !defined('AWS_KEY'))
{
throw new PAS_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
}
if (!$secret_key && !defined('AWS_SECRET_KEY'))
{
throw new PAS_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
}
if (!$assoc_id && !defined('AWS_ASSOC_ID'))
{
throw new PAS_Exception('No Amazon Associates ID was passed into the constructor, nor was it set in the AWS_ASSOC_ID constant.');
}
return parent::__construct($key, $secret_key, null, $assoc_id);
}
/*%******************************************************************************************%*/
// SET CUSTOM SETTINGS
/**
* Method: set_locale()
* Override the default locale to use for PAS requests.
*
* Access:
* public
*
* Parameters:
* locale - _string_ (Optional) The locale to use. Allows PAS_LOCALE_US, PAS_LOCALE_UK, PAS_LOCALE_CANADA, PAS_LOCALE_FRANCE, PAS_LOCALE_GERMANY, PAS_LOCALE_JAPAN
*
* Examples:
* example::pas/set_locale.phpt:
* example::pas/set_locale7.phpt:
*
* Returns:
* void
*/
public function set_locale($locale = null)
{
$this->locale = $locale;
}
/*%******************************************************************************************%*/
// CORE FUNCTIONALITY
/**
* Method: authenticate()
* Construct a URL to request from Amazon, request it, and return a formatted response.
*
* Access:
* public
*
* Parameters:
* action - _string_ (Required) Indicates the action to perform.
* opt - _array_ (Optional) Associative array of parameters. See the individual methods for allowed keys.
* locale - _string_ (Optional) Which Amazon-supported locale do we use? Defaults to United States.
*
* Returns:
* <ResponseCore> object
*/
public function pas_authenticate($action, $opt = null, $locale = null)
{
// If there is no locale, use the default one.
if ($locale === null)
{
// Was this set with set_locale()?
if ($this->locale !== null)
{
$locale = $this->locale;
}
// Fall back to the one set in the config file.
else
{
$locale = (defined('AWS_DEFAULT_LOCALE')) ? AWS_DEFAULT_LOCALE : null;
}
}
// Determine the hostname
switch ($locale)
{
// United Kingdom
case PAS_LOCALE_UK:
$hostname = 'ecs.amazonaws.co.uk';
break;
// Canada
case PAS_LOCALE_CANADA:
$hostname = 'ecs.amazonaws.ca';
break;
// France
case PAS_LOCALE_FRANCE:
$hostname = 'ecs.amazonaws.fr';
break;
// Germany
case PAS_LOCALE_GERMANY:
$hostname = 'ecs.amazonaws.de';
break;
// Japan
case PAS_LOCALE_JAPAN:
$hostname = 'ecs.amazonaws.jp';
break;
// Default to United States
default:
$hostname = 'ecs.amazonaws.com';
break;
}
// Use alternate hostname, if one exists.
if ($this->hostname)
{
$hostname = $this->hostname;
}
$return_curl_handle = false;
$key_prepend = 'AWSAccessKeyId=' . $this->key . '&';
// Manage the key-value pairs that are used in the query.
$query['Operation'] = $action;
$query['Service'] = 'AWSECommerceService';
$query['SignatureMethod'] = 'HmacSHA256';
$query['SignatureVersion'] = 2;
$query['Timestamp'] = gmdate(DATE_FORMAT_ISO8601, time() + $this->adjust_offset);
$query['Version'] = $this->api_version;
// Merge in any options that were passed in
if (is_array($opt))
{
$query = array_merge($query, $opt);
}
$return_curl_handle = isset($query['returnCurlHandle']) ? $query['returnCurlHandle'] : false;
unset($query['returnCurlHandle']);
// Do a case-insensitive, natural order sort on the array keys.
uksort($query, 'strcasecmp');
// Create the string that needs to be hashed.
$canonical_query_string = $key_prepend . $this->util->to_signable_string($query);
// Set the proper verb.
$verb = HTTP_GET;
// Set the proper path
$path = '/onca/xml';
// Prepare the string to sign
$stringToSign = "$verb\n$hostname\n$path\n$canonical_query_string";
// Hash the AWS secret key and generate a signature for the request.
$query['Signature'] = $this->util->hex_to_base64(hash_hmac('sha256', $stringToSign, $this->secret_key));
// Generate the querystring from $query
$querystring = $key_prepend . $this->util->to_query_string($query);
// Gather information to pass along to other classes.
$helpers = array(
'utilities' => $this->utilities_class,
'request' => $this->request_class,
'response' => $this->response_class,
);
// Compose the request.
$request_url = $this->enable_ssl ? 'https://' : 'http://';
$request_url .= $hostname;
$request_url .= $path;
$request_url .= '?' . $querystring;
$request = new $this->request_class($request_url, $this->set_proxy, $helpers);
$request->set_useragent(CLOUDFUSION_USERAGENT);
// If we have a "true" value for returnCurlHandle, do that instead of completing the request.
if ($return_curl_handle)
{
return $request->prep_request();
}
// Send!
$request->send_request();
// Prepare the response.
$headers = $request->get_response_header();
$headers['x-tarzan-requesturl'] = $request_url;
$headers['x-tarzan-stringtosign'] = $stringToSign;
$data = new $this->response_class($headers, new SimpleXMLElement($request->get_response_body()), $request->get_response_code());
// Return!
return $data;
}
/*%******************************************************************************************%*/
// BROWSE NODE LOOKUP
/**
* Method: browse_node_lookup()
* Given a browse node ID, <browse_node_lookup()> returns the specified browse node's name, children, and ancestors. The names and browse node IDs of the children and ancestor browse nodes are also returned. <browse_node_lookup()> enables you to traverse the browse node hierarchy to find a browse node.
*
* If you added your Associates ID to the config.inc.php file, or you passed it into the AmazonPAS() constructor, it will be passed along in this request automatically.
*
* Access:
* public
*
* Parameters:
* browse_node_id - _integer_ (Required) A positive integer assigned by Amazon that uniquely identifies a product category.
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
* locale - _string_ (Optional) Which Amazon-supported locale do we use? Defaults to United States.
*
* Keys for the $opt parameter:
* THIS IS AN INCOMPLETE LIST. For the latest information, check the AWS documentation page (noted below), or run the <help()> method (noted in the examples below).
*
* ContentType - _string_ (Optional) Specifies the format of the content in the response. Generally, ContentType should only be changed for REST requests when the Style parameter is set to an XSLT stylesheet. For example, to transform your Amazon Associates Web Service response into HTML, set ContentType to text/html. Allows 'text/xml' and 'text/html'. Defaults to 'text/xml'.
* MerchantId - _string_ (Optional) An alphanumeric token distributed by Amazon that uniquely identifies a merchant. Allows 'All', 'Amazon', 'FeaturedBuyBoxMerchant', or a specific Merchant ID. Defaults to 'Amazon'.
* ResponseGroup - _string_ (Optional) Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas. Allows 'BrowseNodeInfo' (default), 'NewReleases', 'TopSellers'.
* returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
* Style - _string_ (Optional) Controls the format of the data returned in Amazon Associates Web Service responses. Set this parameter to "XML," the default, to generate a pure XML response. Set this parameter to the URL of an XSLT stylesheet to have Amazon Associates Web Service transform the XML response. See ContentType.
* Validate - _boolean_ (Optional) Prevents an operation from executing. Set the Validate parameter to True to test your request without actually executing it. When present, Validate must equal True; the default value is False. If a request is not actually executed (Validate=True), only a subset of the errors for a request may be returned because some errors (for example, no_exact_matches) are only generated during the execution of a request. Defaults to FALSE.
* XMLEscaping - _string_ (Optional) Specifies whether responses are XML-encoded in a single pass or a double pass. By default, XMLEscaping is Single, and Amazon Associates Web Service responses are encoded only once in XML. For example, if the response data includes an ampersand character (&), the character is returned in its regular XML encoding (&). If XMLEscaping is Double, the same ampersand character is XML-encoded twice (&). The Double value for XMLEscaping is useful in some clients, such as PHP, that do not decode text within XML elements. Defaults to 'Single'.
*
* Returns:
* <ResponseCore> object
*
* Examples:
* example::pas/help_browse_node_lookup.php:
* example::pas/browse_node_lookup.phpt:
* example::pas/browse_node_lookup2.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/BrowseNodeLookup.html
*/
public function browse_node_lookup($browse_node_id, $opt = null, $locale = null)
{
if (!$opt) $opt = array();
$opt['BrowseNodeId'] = $browse_node_id;
if (isset($this->assoc_id))
{
$opt['AssociateTag'] = $this->assoc_id;
}
return $this->pas_authenticate('BrowseNodeLookup', $opt, $locale);
}
/*%******************************************************************************************%*/
// CART METHODS
/**
* Method: cart_add()
* Enables you to add items to an existing remote shopping cart. <cart_add()> can only be used to place a new item in a shopping cart. It cannot be used to increase the quantity of an item already in the cart. If you would like to increase the quantity of an item that is already in the cart, you must use the <cart_modify()> operation.
*
* You add an item to a cart by specifying the item's OfferListingId, or ASIN and ListItemId. Once in a cart, an item can only be identified by its CartItemId. That is, an item in a cart cannot be accessed by its ASIN or OfferListingId. CartItemId is returned by <cart_create()>, <cart_get()>, and <cart_add()>.
*
* To add items to a cart, you must specify the cart using the CartId and HMAC values, which are returned by the <cart_create()> operation.
*
* If you added your Associates ID to the config.inc.php file, or you passed it into the AmazonPAS() constructor, it will be passed along in this request automatically.
*
* Access:
* public
*
* Parameters:
* cart_id - _string_ (Required) Alphanumeric token returned by <cart_create()> that identifies a cart.
* hmac - _string_ (Required) Encrypted alphanumeric token returned by <cart_create()> that authorizes access to a cart.
* offer_listing_id - _string|array_ (Required) Either a string containing the Offer ID to add, or an associative array where the Offer ID is the key and the quantity is the value. An offer listing ID is an alphanumeric token that uniquely identifies an item. Use the OfferListingId instead of an item's ASIN to add the item to the cart.
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
* locale - _string_ (Optional) Which Amazon-supported locale do we use? Defaults to United States.
*
* Keys for the $opt parameter:
* THIS IS AN INCOMPLETE LIST. For the latest information, check the AWS documentation page (noted below), or run the <help()> method (noted in the examples below).
*
* ContentType - _string_ (Optional) Specifies the format of the content in the response. Generally, ContentType should only be changed for REST requests when the Style parameter is set to an XSLT stylesheet. For example, to transform your Amazon Associates Web Service response into HTML, set ContentType to text/html. Allows 'text/xml' and 'text/html'. Defaults to 'text/xml'.
* MergeCart - _boolean_ (Optional) A boolean value that when True specifies that the items in a customer's remote shopping cart are added to the customer's Amazon retail shopping cart. This occurs when the customer elects to purchase the items in their remote shopping cart. When the value is False the remote shopping cart contents are not added to the retail shopping cart. Instead, the customer is sent directly to the Order Pipeline when they elect to purchase the items in their cart. This parameter is valid only in the US locale. In all other locales, the parameter is invalid but the request behaves as though the value were set to True.
* MerchantId - _string_ (Optional) An alphanumeric token distributed by Amazon that uniquely identifies a merchant. Allows 'All', 'Amazon', 'FeaturedBuyBoxMerchant', or a specific Merchant ID. Defaults to 'Amazon'.
* ResponseGroup - _string_ (Optional) Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas.
* returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
* Style - _string_ (Optional) Controls the format of the data returned in Amazon Associates Web Service responses. Set this parameter to "XML," the default, to generate a pure XML response. Set this parameter to the URL of an XSLT stylesheet to have Amazon Associates Web Service transform the XML response. See ContentType.
* Validate - _boolean_ (Optional) Prevents an operation from executing. Set the Validate parameter to True to test your request without actually executing it. When present, Validate must equal True; the default value is False. If a request is not actually executed (Validate=True), only a subset of the errors for a request may be returned because some errors (for example, no_exact_matches) are only generated during the execution of a request. Defaults to FALSE.
* XMLEscaping - _string_ (Optional) Specifies whether responses are XML-encoded in a single pass or a double pass. By default, XMLEscaping is Single, and Amazon Associates Web Service responses are encoded only once in XML. For example, if the response data includes an ampersand character (&), the character is returned in its regular XML encoding (&). If XMLEscaping is Double, the same ampersand character is XML-encoded twice (&). The Double value for XMLEscaping is useful in some clients, such as PHP, that do not decode text within XML elements. Defaults to 'Single'.
*
* Returns:
* <ResponseCore> object
*
* Examples:
* example::pas/help_cart_add.php:
* example::pas/cart_add.phpt:
* example::pas/cart_add2.phpt:
* example::pas/cart_add3.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/CartAdd.html
*/
public function cart_add($cart_id, $hmac, $offer_listing_id, $opt = null, $locale = null)
{
if (!$opt) $opt = array();
$opt['CartId'] = $cart_id;
$opt['HMAC'] = $hmac;
if (is_array($offer_listing_id))
{
$count = 1;
foreach ($offer_listing_id as $offer => $quantity)
{
$opt['Item.' . $count . '.OfferListingId'] = $offer;
$opt['Item.' . $count . '.Quantity'] = $quantity;
$count++;
}
}
else
{
$opt['Item.1.OfferListingId'] = $offer_listing_id;
$opt['Item.1.Quantity'] = 1;
}
if (isset($this->assoc_id))
{
$opt['AssociateTag'] = $this->assoc_id;
}
return $this->pas_authenticate('CartAdd', $opt, $locale);
}
/**
* Method: cart_clear()
* Enables you to remove all of the items in a remote shopping cart, including SavedForLater items. To remove only some of the items in a cart or to reduce the quantity of one or more items, use <cart_modify()>.
*
* To delete all of the items from a remote shopping cart, you must specify the cart using the CartId and HMAC values, which are returned by the <cart_create()> operation. A value similar to the HMAC, URLEncodedHMAC, is also returned. This value is the URL encoded version of the HMAC. This encoding is necessary because some characters, such as + and /, cannot be included in a URL. Rather than encoding the HMAC yourself, use the URLEncodedHMAC value for the HMAC parameter.
*
* <cart_clear()> does not work after the customer has used the PurchaseURL to either purchase the items or merge them with the items in their Amazon cart. Carts exist even though they have been emptied. The lifespan of a cart is 7 days since the last time it was acted upon. For example, if a cart created 6 days ago is modified, the cart lifespan is reset to 7 days.
*
* If you added your Associates ID to the config.inc.php file, or you passed it into the AmazonPAS() constructor, it will be passed along in this request automatically.
*
* Access:
* public
*
* Parameters:
* cart_id - _string_ (Required) Alphanumeric token returned by <cart_create()> that identifies a cart.
* hmac - _string_ (Required) Encrypted alphanumeric token returned by <cart_create()> that authorizes access to a cart.
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
* locale - _string_ (Optional) Which Amazon-supported locale do we use? Defaults to United States.
*
* Keys for the $opt parameter:
* THIS IS AN INCOMPLETE LIST. For the latest information, check the AWS documentation page (noted below), or run the <help()> method (noted in the examples below).
*
* ContentType - _string_ (Optional) Specifies the format of the content in the response. Generally, ContentType should only be changed for REST requests when the Style parameter is set to an XSLT stylesheet. For example, to transform your Amazon Associates Web Service response into HTML, set ContentType to text/html. Allows 'text/xml' and 'text/html'. Defaults to 'text/xml'.
* MergeCart - _boolean_ (Optional) A boolean value that when True specifies that the items in a customer's remote shopping cart are added to the customer's Amazon retail shopping cart. This occurs when the customer elects to purchase the items in their remote shopping cart. When the value is False the remote shopping cart contents are not added to the retail shopping cart. Instead, the customer is sent directly to the Order Pipeline when they elect to purchase the items in their cart. This parameter is valid only in the US locale. In all other locales, the parameter is invalid but the request behaves as though the value were set to True.
* MerchantId - _string_ (Optional) An alphanumeric token distributed by Amazon that uniquely identifies a merchant. Allows 'All', 'Amazon', 'FeaturedBuyBoxMerchant', or a specific Merchant ID. Defaults to 'Amazon'.
* ResponseGroup - _string_ (Optional) Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas.
* returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
* Style - _string_ (Optional) Controls the format of the data returned in Amazon Associates Web Service responses. Set this parameter to "XML," the default, to generate a pure XML response. Set this parameter to the URL of an XSLT stylesheet to have Amazon Associates Web Service transform the XML response. See ContentType.
* Validate - _boolean_ (Optional) Prevents an operation from executing. Set the Validate parameter to True to test your request without actually executing it. When present, Validate must equal True; the default value is False. If a request is not actually executed (Validate=True), only a subset of the errors for a request may be returned because some errors (for example, no_exact_matches) are only generated during the execution of a request. Defaults to FALSE.
* XMLEscaping - _string_ (Optional) Specifies whether responses are XML-encoded in a single pass or a double pass. By default, XMLEscaping is Single, and Amazon Associates Web Service responses are encoded only once in XML. For example, if the response data includes an ampersand character (&), the character is returned in its regular XML encoding (&). If XMLEscaping is Double, the same ampersand character is XML-encoded twice (&). The Double value for XMLEscaping is useful in some clients, such as PHP, that do not decode text within XML elements. Defaults to 'Single'.
*
* Returns:
* <ResponseCore> object
*
* Examples:
* example::pas/help_cart_clear.php:
* example::pas/cart_clear.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/CartClear.html
*/
public function cart_clear($cart_id, $hmac, $opt = null, $locale = null)
{
if (!$opt) $opt = array();
$opt['CartId'] = $cart_id;
$opt['HMAC'] = $hmac;
if (isset($this->assoc_id))
{
$opt['AssociateTag'] = $this->assoc_id;
}
return $this->pas_authenticate('CartClear', $opt, $locale);
}
/**
* Method: cart_create()
* Enables you to create a remote shopping cart. A shopping cart is the metaphor used by most e-commerce solutions. It is a temporary data storage structure that resides on Amazon servers. The structure contains the items a customer wants to buy. In Amazon Associates Web Service, the shopping cart is considered remote because it is hosted by Amazon servers. In this way, the cart is remote to the vendor's web site where the customer views and selects the items they want to purchase.
*
* Once you add an item to a cart by specifying the item's ListItemId and ASIN, or OfferListing ID, the item is assigned a CartItemId and accessible only by that value. That is, in subsequent requests, an item in a cart cannot be accessed by its ListItemId and ASIN, or OfferListingId.
*
* Because the contents of a cart can change for different reasons, such as item availability, you should not keep a copy of a cart locally. Instead, use the other cart operations to modify the cart contents. For example, to retrieve contents of the cart, which are represented by CartItemIds, use <cart_get()>.
*
* Available products are added as cart items. Unavailable items, for example, items out of stock, discontinued, or future releases, are added as SaveForLaterItems. No error is generated. The Amazon database changes regularly. You may find a product with an offer listing ID but by the time the item is added to the cart the product is no longer available. The checkout page in the Order Pipeline clearly lists items that are available and those that are SaveForLaterItems.
*
* It is impossible to create an empty shopping cart. You have to add at least one item to a shopping cart using a single <cart_create()> request. You can add specific quantities (up to 999) of each item. <cart_create()> can be used only once in the life cycle of a cart. To modify the contents of the cart, use one of the other cart operations.
*
* Carts cannot be deleted. They expire automatically after being unused for 7 days. The lifespan of a cart restarts, however, every time a cart is modified. In this way, a cart can last for more than 7 days. If, for example, on day 6, the customer modifies a cart, the 7 day countdown starts over.
*
* If you added your Associates ID to the config.inc.php file, or you passed it into the AmazonPAS() constructor, it will be passed along in this request automatically.
*
* Access:
* public
*
* Parameters:
* offer_listing_id - _string|array_ (Required) Either a string containing the Offer ID to add, or an associative array where the Offer ID is the key and the quantity is the value. An offer listing ID is an alphanumeric token that uniquely identifies an item. Use the OfferListingId instead of an item's ASIN to add the item to the cart.
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
* locale - _string_ (Optional) Which Amazon-supported locale do we use? Defaults to United States.
*
* Keys for the $opt parameter:
* THIS IS AN INCOMPLETE LIST. For the latest information, check the AWS documentation page (noted below), or run the <help()> method (noted in the examples below).
*
* ContentType - _string_ (Optional) Specifies the format of the content in the response. Generally, ContentType should only be changed for REST requests when the Style parameter is set to an XSLT stylesheet. For example, to transform your Amazon Associates Web Service response into HTML, set ContentType to text/html. Allows 'text/xml' and 'text/html'. Defaults to 'text/xml'.
* MergeCart - _boolean_ (Optional) A boolean value that when True specifies that the items in a customer's remote shopping cart are added to the customer's Amazon retail shopping cart. This occurs when the customer elects to purchase the items in their remote shopping cart. When the value is False the remote shopping cart contents are not added to the retail shopping cart. Instead, the customer is sent directly to the Order Pipeline when they elect to purchase the items in their cart. This parameter is valid only in the US locale. In all other locales, the parameter is invalid but the request behaves as though the value were set to True.
* MerchantId - _string_ (Optional) An alphanumeric token distributed by Amazon that uniquely identifies a merchant. Allows 'All', 'Amazon', 'FeaturedBuyBoxMerchant', or a specific Merchant ID. Defaults to 'Amazon'.
* ResponseGroup - _string_ (Optional) Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas.
* returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
* Style - _string_ (Optional) Controls the format of the data returned in Amazon Associates Web Service responses. Set this parameter to "XML," the default, to generate a pure XML response. Set this parameter to the URL of an XSLT stylesheet to have Amazon Associates Web Service transform the XML response. See ContentType.
* Validate - _boolean_ (Optional) Prevents an operation from executing. Set the Validate parameter to True to test your request without actually executing it. When present, Validate must equal True; the default value is False. If a request is not actually executed (Validate=True), only a subset of the errors for a request may be returned because some errors (for example, no_exact_matches) are only generated during the execution of a request. Defaults to FALSE.
* XMLEscaping - _string_ (Optional) Specifies whether responses are XML-encoded in a single pass or a double pass. By default, XMLEscaping is Single, and Amazon Associates Web Service responses are encoded only once in XML. For example, if the response data includes an ampersand character (&), the character is returned in its regular XML encoding (&). If XMLEscaping is Double, the same ampersand character is XML-encoded twice (&). The Double value for XMLEscaping is useful in some clients, such as PHP, that do not decode text within XML elements. Defaults to 'Single'.
*
* Returns:
* <ResponseCore> object
*
* Examples:
* example::pas/help_cart_create.php:
* example::pas/cart_create.phpt:
* example::pas/cart_create2.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/CartCreate.html
*/
public function cart_create($offer_listing_id, $opt = null, $locale = null)
{
if (!$opt) $opt = array();
if (is_array($offer_listing_id))
{
$count = 1;
foreach ($offer_listing_id as $offer => $quantity)
{
$opt['Item.' . $count . '.OfferListingId'] = $offer;
$opt['Item.' . $count . '.Quantity'] = $quantity;
$count++;
}
}
else
{
$opt['Item.1.OfferListingId'] = $offer_listing_id;
$opt['Item.1.Quantity'] = 1;
}
if (isset($this->assoc_id))
{
$opt['AssociateTag'] = $this->assoc_id;
}
return $this->pas_authenticate('CartCreate', $opt, $locale);
}
/**
* Method: cart_get()
* Enables you to retrieve the IDs, quantities, and prices of all of the items, including SavedForLater items in a remote shopping cart.
*
* Because the contents of a cart can change for different reasons, such as availability, you should not keep a copy of a cart locally. Instead, use <cart_get()> to retrieve the items in a remote shopping cart. To retrieve the items in a cart, you must specify the cart using the CartId and HMAC values, which are returned in the <cart_create()> operation. A value similar to HMAC, URLEncodedHMAC, is also returned.
*
* This value is the URL encoded version of the HMAC. This encoding is necessary because some characters, such as + and /, cannot be included in a URL. Rather than encoding the HMAC yourself, use the URLEncodedHMAC value for the HMAC parameter.
*
* <cart_get()> does not work after the customer has used the PurchaseURL to either purchase the items or merge them with the items in their Amazon cart.
*
* Access:
* public
*
* Parameters:
* cart_id - _string_ (Required) Alphanumeric token returned by <cart_create()> that identifies a cart.
* hmac - _string_ (Required) Encrypted alphanumeric token returned by <cart_create()> that authorizes access to a cart.
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
* locale - _string_ (Optional) Which Amazon-supported locale do we use? Defaults to United States.
*
* Keys for the $opt parameter:
* THIS IS AN INCOMPLETE LIST. For the latest information, check the AWS documentation page (noted below), or run the <help()> method (noted in the examples below).
*
* CartItemId - _string_ (Optional) Alphanumeric token that uniquely identifies an item in a cart. Once an item, specified by an ASIN or OfferListingId, has been added to a cart, you must use the CartItemId to refer to it. The other identifiers will not work.
* ContentType - _string_ (Optional) Specifies the format of the content in the response. Generally, ContentType should only be changed for REST requests when the Style parameter is set to an XSLT stylesheet. For example, to transform your Amazon Associates Web Service response into HTML, set ContentType to text/html. Allows 'text/xml' and 'text/html'. Defaults to 'text/xml'.
* MergeCart - _boolean_ (Optional) A boolean value that when True specifies that the items in a customer's remote shopping cart are added to the customer's Amazon retail shopping cart. This occurs when the customer elects to purchase the items in their remote shopping cart. When the value is False the remote shopping cart contents are not added to the retail shopping cart. Instead, the customer is sent directly to the Order Pipeline when they elect to purchase the items in their cart. This parameter is valid only in the US locale. In all other locales, the parameter is invalid but the request behaves as though the value were set to True.
* MerchantId - _string_ (Optional) An alphanumeric token distributed by Amazon that uniquely identifies a merchant. Allows 'All', 'Amazon', 'FeaturedBuyBoxMerchant', or a specific Merchant ID. Defaults to 'Amazon'.
* ResponseGroup - _string_ (Optional) Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas.
* returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
* Style - _string_ (Optional) Controls the format of the data returned in Amazon Associates Web Service responses. Set this parameter to "XML," the default, to generate a pure XML response. Set this parameter to the URL of an XSLT stylesheet to have Amazon Associates Web Service transform the XML response. See ContentType.
* Validate - _boolean_ (Optional) Prevents an operation from executing. Set the Validate parameter to True to test your request without actually executing it. When present, Validate must equal True; the default value is False. If a request is not actually executed (Validate=True), only a subset of the errors for a request may be returned because some errors (for example, no_exact_matches) are only generated during the execution of a request. Defaults to FALSE.
* XMLEscaping - _string_ (Optional) Specifies whether responses are XML-encoded in a single pass or a double pass. By default, XMLEscaping is Single, and Amazon Associates Web Service responses are encoded only once in XML. For example, if the response data includes an ampersand character (&), the character is returned in its regular XML encoding (&). If XMLEscaping is Double, the same ampersand character is XML-encoded twice (&). The Double value for XMLEscaping is useful in some clients, such as PHP, that do not decode text within XML elements. Defaults to 'Single'.
*
* Returns:
* <ResponseCore> object
*
* Examples:
* example::pas/help_cart_get.php:
* example::pas/cart_get.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/CartGet.html
*/
public function cart_get($cart_id, $hmac, $opt = null, $locale = null)
{
if (!$opt) $opt = array();
$opt['CartId'] = $cart_id;
$opt['HMAC'] = $hmac;
if (isset($this->assoc_id))
{
$opt['AssociateTag'] = $this->assoc_id;
}
return $this->pas_authenticate('CartGet', $opt, $locale);
}
/**
* Method: cart_modify()
* Enables you to change the quantity of items that are already in a remote shopping cart, move items from the active area of a cart to the SaveForLater area or the reverse, and change the MergeCart setting.
*
* To modify the number of items in a cart, you must specify the cart using the CartId and HMAC values that are returned in the <cart_create()> operation. A value similar to HMAC, URLEncodedHMAC, is also returned. This value is the URL encoded version of the HMAC. This encoding is necessary because some characters, such as + and /, cannot be included in a URL. Rather than encoding the HMAC yourself, use the URLEncodedHMAC value for the HMAC parameter.
*
* You can use <cart_modify()> to modify the number of items in a remote shopping cart by setting the value of the Quantity parameter appropriately. You can eliminate an item from a cart by setting the value of the Quantity parameter to zero. Or, you can double the number of a particular item in the cart by doubling its Quantity. You cannot, however, use <cart_modify()> to add new items to a cart.
*
* Access:
* public
*
* Parameters:
* cart_id - _string_ (Required) Alphanumeric token returned by <cart_create()> that identifies a cart.
* hmac - _string_ (Required) Encrypted alphanumeric token returned by <cart_create()> that authorizes access to a cart.
* cart_item_id - _array_ (Required) Associative array that specifies an item to be modified in the cart where N is a positive integer between 1 and 10, inclusive. Up to ten items can be modified at a time. CartItemId is neither an ASIN nor an OfferListingId. It is, instead, an alphanumeric token returned by <cart_create()> and <cart_add()>. This parameter is used in conjunction with Item.N.Quantity to modify the number of items in a cart. Also, instead of adjusting the quantity, you can set 'SaveForLater' or 'MoveToCart' as actions instead.
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
* locale - _string_ (Optional) Which Amazon-supported locale do we use? Defaults to United States.
*
* Keys for the $opt parameter:
* THIS IS AN INCOMPLETE LIST. For the latest information, check the AWS documentation page (noted below), or run the <help()> method (noted in the examples below).
*
* Action - _string_ (Optional) Change cart items to move items to the Saved-For-Later area, or change Saved-For- Later (SaveForLater) items to the active cart area (MoveToCart).
* ContentType - _string_ (Optional) Specifies the format of the content in the response. Generally, ContentType should only be changed for REST requests when the Style parameter is set to an XSLT stylesheet. For example, to transform your Amazon Associates Web Service response into HTML, set ContentType to text/html. Allows 'text/xml' and 'text/html'. Defaults to 'text/xml'.
* ListItemId - _string_ (Optional) The ListItemId parameter is returned by the ListItems response group. The parameter identifies an item on a list, such as a wishlist. To add this item to a cart, you must include in the <cart_create()> request the item's ASIN and ListItemId. The ListItemId includes the name and address of the list owner, which the ASIN alone does not.
* MergeCart - _boolean_ (Optional) A boolean value that when True specifies that the items in a customer's remote shopping cart are added to the customer's Amazon retail shopping cart. This occurs when the customer elects to purchase the items in their remote shopping cart. When the value is False the remote shopping cart contents are not added to the retail shopping cart. Instead, the customer is sent directly to the Order Pipeline when they elect to purchase the items in their cart. This parameter is valid only in the US locale. In all other locales, the parameter is invalid but the request behaves as though the value were set to True.
* MerchantId - _string_ (Optional) An alphanumeric token distributed by Amazon that uniquely identifies a merchant. Allows 'All', 'Amazon', 'FeaturedBuyBoxMerchant', or a specific Merchant ID. Defaults to 'Amazon'.
* ResponseGroup - _string_ (Optional) Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas.
* returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
* Style - _string_ (Optional) Controls the format of the data returned in Amazon Associates Web Service responses. Set this parameter to "XML," the default, to generate a pure XML response. Set this parameter to the URL of an XSLT stylesheet to have Amazon Associates Web Service transform the XML response. See ContentType.
* Validate - _boolean_ (Optional) Prevents an operation from executing. Set the Validate parameter to True to test your request without actually executing it. When present, Validate must equal True; the default value is False. If a request is not actually executed (Validate=True), only a subset of the errors for a request may be returned because some errors (for example, no_exact_matches) are only generated during the execution of a request. Defaults to FALSE.
* XMLEscaping - _string_ (Optional) Specifies whether responses are XML-encoded in a single pass or a double pass. By default, XMLEscaping is Single, and Amazon Associates Web Service responses are encoded only once in XML. For example, if the response data includes an ampersand character (&), the character is returned in its regular XML encoding (&). If XMLEscaping is Double, the same ampersand character is XML-encoded twice (&). The Double value for XMLEscaping is useful in some clients, such as PHP, that do not decode text within XML elements. Defaults to 'Single'.
*
* Returns:
* <ResponseCore> object
*
* Examples:
* example::pas/help_cart_modify.php:
* example::pas/cart_modify.phpt:
* example::pas/cart_modify2.phpt:
* example::pas/cart_modify3.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/CartModify.html
*/
public function cart_modify($cart_id, $hmac, $cart_item_id, $opt = null, $locale = null)
{
if (!$opt) $opt = array();
$opt['CartId'] = $cart_id;
$opt['HMAC'] = $hmac;
if (is_array($cart_item_id))
{
$count = 1;
foreach ($cart_item_id as $offer => $quantity)
{
$action = is_numeric($quantity) ? 'Quantity' : 'Action';
$opt['Item.' . $count . '.CartItemId'] = $offer;
$opt['Item.' . $count . '.' . $action] = $quantity;
$count++;
}
}
else
{
throw new PAS_Exception('$cart_item_id MUST be an array. See the ' . CLOUDFUSION_NAME . ' documentation for more details.');
}
if (isset($this->assoc_id))
{
$opt['AssociateTag'] = $this->assoc_id;
}
return $this->pas_authenticate('CartModify', $opt, $locale);
}
/*%******************************************************************************************%*/
// CUSTOMER CONTENT METHODS
/**
* Method: customer_content_lookup()
* For a given customer ID, the <customer_content_lookup()> operation retrieves all of the information a customer has made public about themselves on Amazon. Such information includes some or all of the following: About Me, Birthday, City, State, Country, Customer Reviews, Customer ID, Name, Nickname, Wedding Registry, or WishList. To find a customer ID, use the <customer_content_search()> operation.
*
* If you added your Associates ID to the config.inc.php file, or you passed it into the AmazonPAS() constructor, it will be passed along in this request automatically.
*
* Access:
* public
*
* Parameters:
* customer_id - _string_ (Required) An alphanumeric token assigned by Amazon that uniquely identifies a customer. Only one customer_id can be submitted at a time in <customer_content_lookup()>.
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
* locale - _string_ (Optional) Which Amazon-supported locale do we use? Defaults to United States.
*
* Keys for the $opt parameter:
* THIS IS AN INCOMPLETE LIST. For the latest information, check the AWS documentation page (noted below), or run the <help()> method (noted in the examples below).
*
* ContentType - _string_ (Optional) Specifies the format of the content in the response. Generally, ContentType should only be changed for REST requests when the Style parameter is set to an XSLT stylesheet. For example, to transform your Amazon Associates Web Service response into HTML, set ContentType to text/html. Allows 'text/xml' and 'text/html'. Defaults to 'text/xml'.
* MerchantId - _string_ (Optional) An alphanumeric token distributed by Amazon that uniquely identifies a merchant. Allows 'All', 'Amazon', 'FeaturedBuyBoxMerchant', or a specific Merchant ID. Defaults to 'Amazon'.
* ResponseGroup - _string_ (Optional) Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas. Allows 'CustomerInfo' (default), 'CustomerReviews', 'CustomerLists', 'CustomerFull', 'TaggedGuides', 'TaggedItems', 'TaggedListmaniaLists', 'TagsSummary', or 'Tags'.
* returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
* ReviewPage - _integer_ (Optional) A positive integer that specifies the page of reviews to read. There are ten reviews per page. For example, to read reviews 11 through 20, specify ReviewPage=2. The total number of pages is returned in the TotalPages response tag.
* Style - _string_ (Optional) Controls the format of the data returned in Amazon Associates Web Service responses. Set this parameter to "XML," the default, to generate a pure XML response. Set this parameter to the URL of an XSLT stylesheet to have Amazon Associates Web Service transform the XML response. See ContentType.
* TagPage - _integer_ (Optional) Specifies the page of results to return. There are ten results on a page. The maximum page number is 400.
* TagsPerPage - _integer_ (Optional) The number of tags to return that are associated with a specified item.
* TagSort - _string_ (Optional) Specifies the sorting order for the results. Allows 'FirstUsed', 'LastUsed', 'Name', or 'Usages' (default)
* Validate - _boolean_ (Optional) Prevents an operation from executing. Set the Validate parameter to True to test your request without actually executing it. When present, Validate must equal True; the default value is False. If a request is not actually executed (Validate=True), only a subset of the errors for a request may be returned because some errors (for example, no_exact_matches) are only generated during the execution of a request. Defaults to FALSE.
* XMLEscaping - _string_ (Optional) Specifies whether responses are XML-encoded in a single pass or a double pass. By default, XMLEscaping is Single, and Amazon Associates Web Service responses are encoded only once in XML. For example, if the response data includes an ampersand character (&), the character is returned in its regular XML encoding (&). If XMLEscaping is Double, the same ampersand character is XML-encoded twice (&). The Double value for XMLEscaping is useful in some clients, such as PHP, that do not decode text within XML elements. Defaults to 'Single'.
*
* Returns:
* <ResponseCore> object
*
* Examples:
* example::pas/help_customer_content_lookup.php:
* example::pas/customer_content_lookup.phpt:
* example::pas/customer_content_lookup2.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/CustomerContentLookup.html
* Related - <customer_content_lookup()>, <customer_content_search()>
*/
public function customer_content_lookup($customer_id, $opt = null, $locale = null)
{
if (!$opt) $opt = array();
$opt['CustomerId'] = $customer_id;
if (isset($this->assoc_id))
{
$opt['AssociateTag'] = $this->assoc_id;
}
return $this->pas_authenticate('CustomerContentLookup', $opt, $locale);
}
/**
* Method: customer_content_search()
* For a given customer Email address or name, the <customer_content_search()> operation returns matching customer IDs, names, nicknames, and residence information (city, state, and country). In general, supplying an Email address returns unique results whereas supplying a name more often returns multiple results. This operation is US-only.
*
* If you added your Associates ID to the config.inc.php file, or you passed it into the AmazonPAS() constructor, it will be passed along in this request automatically.
*
* Access:
* public
*
* Parameters:
* email_name - _string_ (Required) Either the email address or the name of the customer you want to look up the ID for.
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
*
* Keys for the $opt parameter:
* THIS IS AN INCOMPLETE LIST. For the latest information, check the AWS documentation page (noted below), or run the <help()> method (noted in the examples below).
*
* ContentType - _string_ (Optional) Specifies the format of the content in the response. Generally, ContentType should only be changed for REST requests when the Style parameter is set to an XSLT stylesheet. For example, to transform your Amazon Associates Web Service response into HTML, set ContentType to text/html. Allows 'text/xml' and 'text/html'. Defaults to 'text/xml'.
* CustomerPage - _integer_ (Optional) A positive integer that specifies the page of customer IDs to return. Up to twenty customer IDs are returned per page. Defaults to 1.
* Email - _string_ (Optional) Besides the first parameter, you can set the email address here.
* MerchantId - _string_ (Optional) An alphanumeric token distributed by Amazon that uniquely identifies a merchant. Allows 'All', 'Amazon', 'FeaturedBuyBoxMerchant', or a specific Merchant ID. Defaults to 'Amazon'.
* Name - _string_ (Optional) Besides the first parameter, you can set the name here.
* ResponseGroup - _string_ (Optional) Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas.
* returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
* Style - _string_ (Optional) Controls the format of the data returned in Amazon Associates Web Service responses. Set this parameter to "XML," the default, to generate a pure XML response. Set this parameter to the URL of an XSLT stylesheet to have Amazon Associates Web Service transform the XML response. See ContentType.
* Validate - _boolean_ (Optional) Prevents an operation from executing. Set the Validate parameter to True to test your request without actually executing it. When present, Validate must equal True; the default value is False. If a request is not actually executed (Validate=True), only a subset of the errors for a request may be returned because some errors (for example, no_exact_matches) are only generated during the execution of a request. Defaults to FALSE.
* XMLEscaping - _string_ (Optional) Specifies whether responses are XML-encoded in a single pass or a double pass. By default, XMLEscaping is Single, and Amazon Associates Web Service responses are encoded only once in XML. For example, if the response data includes an ampersand character (&), the character is returned in its regular XML encoding (&). If XMLEscaping is Double, the same ampersand character is XML-encoded twice (&). The Double value for XMLEscaping is useful in some clients, such as PHP, that do not decode text within XML elements. Defaults to 'Single'.
*
* Returns:
* <ResponseCore> object
*
* Examples:
* example::pas/help_customer_content_search.php:
* example::pas/customer_content_search.phpt:
* example::pas/customer_content_search2.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/CustomerContentSearch.html
* Related - <customer_content_lookup()>, <customer_content_search()>
*/
public function customer_content_search($email_name, $opt = null)
{
if (!$opt) $opt = array();
if (strpos($email_name, '@'))
{
$opt['Email'] = $email_name;
}
else
{
$opt['Name'] = $email_name;
}
if (isset($this->assoc_id))
{
$opt['AssociateTag'] = $this->assoc_id;
}
return $this->pas_authenticate('CustomerContentSearch', $opt, PAS_LOCALE_US);
}
/*%******************************************************************************************%*/
// HELP
/**
* Method: help()
* The Help operation provides information about PAS operations and response groups. For operations, Help lists required and optional request parameters, as well as default and optional response groups the operation can use. For response groups, Help lists the operations that can use the response group as well as the response tags returned by the response group in the XML response.
*
* If you added your Associates ID to the config.inc.php file, or you passed it into the AmazonPAS() constructor, it will be passed along in this request automatically.
*
* Access:
* public
*
* Parameters:
* about - _string_ (Required) Specifies the operation or response group about which you want more information. Allows all PAS operations, all PAS response groups.
* help_type - _string_ (Required) Specifies whether the help topic is an operation or response group. HelpType and About values must both be operations or response groups, not a mixture of the two. Allows 'Operation' or 'ResponseGroup'.
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
* locale - _string_ (Optional) Which Amazon-supported locale do we use? Defaults to United States.
*
* Keys for the $opt parameter:
* THIS IS AN INCOMPLETE LIST. For the latest information, check the AWS documentation page (noted below), or run the <help()> method (noted in the examples below).
*
* ContentType - _string_ (Optional) Specifies the format of the content in the response. Generally, ContentType should only be changed for REST requests when the Style parameter is set to an XSLT stylesheet. For example, to transform your Amazon Associates Web Service response into HTML, set ContentType to text/html. Allows 'text/xml' and 'text/html'. Defaults to 'text/xml'.
* MerchantId - _string_ (Optional) An alphanumeric token distributed by Amazon that uniquely identifies a merchant. Allows 'All', 'Amazon', 'FeaturedBuyBoxMerchant', or a specific Merchant ID. Defaults to 'Amazon'.
* ResponseGroup - _string_ (Optional) Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas. Allows 'Request' or 'Help'.
* returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
* Style - _string_ (Optional) Controls the format of the data returned in Amazon Associates Web Service responses. Set this parameter to "XML," the default, to generate a pure XML response. Set this parameter to the URL of an XSLT stylesheet to have Amazon Associates Web Service transform the XML response. See ContentType.
* Validate - _boolean_ (Optional) Prevents an operation from executing. Set the Validate parameter to True to test your request without actually executing it. When present, Validate must equal True; the default value is False. If a request is not actually executed (Validate=True), only a subset of the errors for a request may be returned because some errors (for example, no_exact_matches) are only generated during the execution of a request. Defaults to FALSE.
* XMLEscaping - _string_ (Optional) Specifies whether responses are XML-encoded in a single pass or a double pass. By default, XMLEscaping is Single, and Amazon Associates Web Service responses are encoded only once in XML. For example, if the response data includes an ampersand character (&), the character is returned in its regular XML encoding (&). If XMLEscaping is Double, the same ampersand character is XML-encoded twice (&). The Double value for XMLEscaping is useful in some clients, such as PHP, that do not decode text within XML elements. Defaults to 'Single'.
*
* Returns:
* <ResponseCore> object
*
* Examples:
* example::pas/help.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/Help.html
*/
public function help($about, $help_type, $opt = null, $locale = null)
{
if (!$opt) $opt = array();
$opt['About'] = $about;
$opt['HelpType'] = $help_type;
if (isset($this->assoc_id))
{
$opt['AssociateTag'] = $this->assoc_id;
}
return $this->pas_authenticate('Help', $opt, $locale);
}
/*%******************************************************************************************%*/
// ITEM METHODS
/**
* Method: item_lookup()
* Given an Item identifier, the ItemLookup operation returns some or all of the item attributes, depending on the response group specified in the request. By default, <item_lookup()> returns an item’s ASIN, DetailPageURL, Manufacturer, ProductGroup, and Title of the item.
*
* If you added your Associates ID to the config.inc.php file, or you passed it into the AmazonPAS() constructor, it will be passed along in this request automatically.
*
* Access:
* public
*
* Parameters:
* item_id - _string_ (Required) A positive integer that unique identifies an item. The meaning of the number is specified by IdType. That is, if IdType is ASIN, the ItemId value is an ASIN. If ItemId is an ASIN, a search index cannot be specified in the request.
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
* locale - _string_ (Optional) Which Amazon-supported locale do we use? Defaults to United States.
*
* Keys for the $opt parameter:
* THIS IS AN INCOMPLETE LIST. For the latest information, check the AWS documentation page (noted below), or run the <help()> method (noted in the examples below).
*
* Condition - _string_ (Optional) Specifies an item's condition. If Condition is set to "All," a separate set of responses is returned for each valid value of Condition. The default value is "New" (not "All"). So, if your request does not return results, consider setting the value to "All." When the value is "New," the ItemSearch Availability parameter cannot be set to "Available." Amazon only sells items that are "New." Allows 'New', 'Used', 'Collectible', 'Refurbished', and 'All'. Defaults to 'New'.
* ContentType - _string_ (Optional) Specifies the format of the content in the response. Generally, ContentType should only be changed for REST requests when the Style parameter is set to an XSLT stylesheet. For example, to transform your Amazon Associates Web Service response into HTML, set ContentType to text/html. Allows 'text/xml' and 'text/html'. Defaults to 'text/xml'.
* IdType - _string_ (Optional) Type of item identifier used to look up an item. All IdTypes except ASINx require a SearchIndex to be specified. SKU requires a MerchantId to be specified also. Allows 'ASIN', 'SKU', 'UPC', 'EAN', 'ISBN' (US only, when search index is Books), and 'JAN'. UPC is not valid in the Canadian locale. Defaults to 'ASIN'.
* MerchantId - _string_ (Optional) An alphanumeric token distributed by Amazon that uniquely identifies a merchant. Allows 'All', 'Amazon', 'FeaturedBuyBoxMerchant', or a specific Merchant ID. Defaults to 'Amazon'.
* OfferPage - _string_ (Optional) Page of offers returned. There are 10 offers per page. To examine offers 11 trough 20, for example, set OfferPage to 2. Allows 1 through 100.
* RelatedItemsPage - _integer_ (Optional) This optional parameter is only valid when the RelatedItems response group is used. Each ItemLookup request can return, at most, ten related items. The RelatedItemsPage value specifies the set of ten related items to return. A value of 2, for example, returns the second set of ten related items.
* RelationshipType - _string_ (Optional) This parameter is required when the RelatedItems response group is used. The type of related item returned is specified by the RelationshipType parameter. Sample values include Episode, Season, and Tracks. For a complete list of types, go to the documentation for "Relationship Types". Required when 'RelatedItems' response group is used.
* ResponseGroup - _string_ (Optional) Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas. Check the documentation for all allowed values.
* returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
* ReviewPage - _integer_ (Optional) Page of reviews returned. There are 5 reviews per page. To examine reviews 6 through 10, for example, set ReviewPage to 2. Allows 1 through 20.
* ReviewSort - _string_ (Optional) Specifies the order in which Reviews are sorted in the return. Allows '-HelpfulVotes', 'HelpfulVotes', '-OverallRating', 'OverallRating', 'SubmissionDate' and '-SubmissionDate'. Defaults to '-SubmissionDate'.
* SearchIndex - _string_ (Optional) The product category to search. Constraint: If ItemIds an ASIN, a search index cannot be specified in the request. Required for for non-ASIN ItemIds. Allows any valid search index. See the "Search Indices" documentation page for more details.
* Style - _string_ (Optional) Controls the format of the data returned in Amazon Associates Web Service responses. Set this parameter to "XML," the default, to generate a pure XML response. Set this parameter to the URL of an XSLT stylesheet to have Amazon Associates Web Service transform the XML response. See ContentType.
* TagPage - _integer_ (Optional) Specifies the page of results to return. There are ten results on a page. Allows 1 through 400.
* TagsPerPage - _integer_ (Optional) The number of tags to return that are associated with a specified item.
* TagSort - _string_ (Optional) Specifies the sorting order for the results. Allows 'FirstUsed', '-FirstUsed', 'LastUsed', '-LastUsed', 'Name', '-Name', 'Usages', and '-Usages'. Defaults to '-Usages'.
* Validate - _boolean_ (Optional) Prevents an operation from executing. Set the Validate parameter to True to test your request without actually executing it. When present, Validate must equal True; the default value is False. If a request is not actually executed (Validate=True), only a subset of the errors for a request may be returned because some errors (for example, no_exact_matches) are only generated during the execution of a request. Defaults to FALSE.
* VariationPage - _string_ (Optional) Page number of variations returned by ItemLookup. By default, ItemLookup returns all variations. Use VariationPage to return a subsection of the response. There are 10 variations per page. To examine offers 11 trough 20, for example, set VariationPage to 2. Allows 1 through 150.
* XMLEscaping - _string_ (Optional) Specifies whether responses are XML-encoded in a single pass or a double pass. By default, XMLEscaping is Single, and Amazon Associates Web Service responses are encoded only once in XML. For example, if the response data includes an ampersand character (&), the character is returned in its regular XML encoding (&). If XMLEscaping is Double, the same ampersand character is XML-encoded twice (&). The Double value for XMLEscaping is useful in some clients, such as PHP, that do not decode text within XML elements. Defaults to 'Single'.
*
* Returns:
* <ResponseCore> object
*
* Examples:
* example::pas/help_item_lookup.php:
* example::pas/item_lookup.phpt:
* example::pas/item_lookup2.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/ItemLookup.html
* Related - <item_lookup()>, <item_search()>
*/
public function item_lookup($item_id, $opt = null, $locale = null)
{
if (!$opt) $opt = array();
$opt['ItemId'] = $item_id;
if (isset($this->assoc_id))
{
$opt['AssociateTag'] = $this->assoc_id;
}
return $this->pas_authenticate('ItemLookup', $opt, $locale);
}
/**
* Method: item_search()
* The <item_search()> operation returns items that satisfy the search criteria, including one or more search indices. <item_search()> is the operation that is used most often in requests. In general, when trying to find an item for sale, you use this operation.
*
* If you added your Associates ID to the config.inc.php file, or you passed it into the AmazonPAS() constructor, it will be passed along in this request automatically.
*
* Access:
* public
*
* Parameters:
* keywords - _string_ (Required) A word or phrase associated with an item. The word or phrase can be in various product fields, including product title, author, artist, description, manufacturer, and so forth. When, for example, the search index equals "MusicTracks", the Keywords parameter enables you to search by song title.
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
* locale - _string_ (Optional) Which Amazon-supported locale do we use? Defaults to United States.
*
* Keys for the $opt parameter:
* THIS IS AN INCOMPLETE LIST. For the latest information, check the AWS documentation page (noted below), or run the <help()> method (noted in the examples below).
*
* Actor - _string_ (Optional) Name of an actor associated with the item. You can enter all or part of the name.
* Artist - _string_ (Optional) Name of an artist associated with the item. You can enter all or part of the name.
* AudienceRating - _string_ (Optional) Movie ratings based on MPAA ratings or age, depending upon the locale. You may specify one or more values in a comma-separated list.
* Author - _string_ (Optional) Name of an author associated with the item. You can enter all or part of the name.
* Availability - _string_ (Optional) Enables ItemSearch to return only those items that are available. This parameter must be used in combination with a merchant ID and Condition. When Availability is set to "Available," the Condition parameter cannot be set to "New".
* Brand - _string_ (Optional) Name of a brand associated with the item. You can enter all or part of the name.
* BrowseNode - _integer_ (Optional) Browse nodes are positive integers that identify product categories.
* City - _string_ (Optional) Name of a city associated with the item. You can enter all or part of the name. This parameter only works in the US locale.
* Composer - _string_ (Optional) Name of an composer associated with the item. You can enter all or part of the name.
* Condition - _string_ (Optional) Use the Condition parameter to filter the offers returned in the product list by condition type. By default, Condition equals "New". If you do not get results, consider changing the value to "All. When the Availability parameter is set to "Available," the Condition parameter cannot be set to "New". ItemSearch returns up to ten search results at a time. Allows 'New', 'Used', 'Collectible', 'Refurbished', 'All'.
* Conductor - _string_ (Optional) Name of a conductor associated with the item. You can enter all or part of the name.
* ContentType - _string_ (Optional) Specifies the format of the content in the response. Generally, ContentType should only be changed for REST requests when the Style parameter is set to an XSLT stylesheet. For example, to transform your Amazon Associates Web Service response into HTML, set ContentType to text/html. Allows 'text/xml' and 'text/html'. Defaults to 'text/xml'.
* Director - _string_ (Optional) Name of a director associated with the item. You can enter all or part of the name.
* ItemPage - _integer_ (Optional) Retrieves a specific page of items from all of the items in a response. Up to ten items are returned on a page unless Condition equals "All." In that case, returns up to three results per Condition, for example, three new, three used, three refurbished, and three collectible items. Or, for example, if there are no collectible or refurbished items being offered, returns three new and three used items. The total number of pages of items found is returned in the TotalPages response tag. Allows 1 through 400.
* Keywords - _string_ (Optional) A word or phrase associated with an item. The word or phrase can be in various product fields, including product title, author, artist, description, manufacturer, and so forth. When, for example, the search index equals "MusicTracks," the Keywords parameter enables you to search by song title.
* Manufacturer - _string_ (Optional) Name of a manufacturer associated with the item. You can enter all or part of the name.
* MaximumPrice - _string_ (Optional) Specifies the maximum price of the items in the response. Prices are in terms of the lowest currency denomination, for example, pennies.
* MerchantId - _string_ (Optional) An alphanumeric token distributed by Amazon that uniquely identifies a merchant. Allows 'All', 'Amazon', 'FeaturedBuyBoxMerchant', or a specific Merchant ID. Defaults to 'Amazon'.
* MinimumPrice - _string_ (Optional) Specifies the minimum price of the items in the response. Prices are in terms of the lowest currency denomination, for example, pennies.
* Neighborhood - _string_ (Optional) Name of a neighborhood You can enter all or part of the name. The neighborhoods are located in one of the valid values for City.
* Orchestra - _string_ (Optional) Name of an orchestra associated with the item. You can enter all or part of the name.
* PostalCode - _string_ (Optional) Postal code of the merchant. In the US, the postal code is the postal code. This parameter enables you to search for items sold in a specified region of a country.
* Power - _string_ (Optional) Performs a book search using a complex query string. Only works when the search index is set equal to "Books".
* Publisher - _string_ (Optional) Name of a publisher associated with the item. You can enter all or part of the name.
* RelatedItemsPage - _integer_ (Optional) This optional parameter is only valid when the RelatedItems response group is used. Each ItemLookup request can return, at most, ten related items. The RelatedItemsPage value specifies the set of ten related items to return. A value of 2, for example, returns the second set of ten related items.
* RelationshipType - _string_ (Optional; Required when RelatedItems response group is used) This parameter is required when the RelatedItems response group is used. The type of related item returned is specified by the RelationshipType parameter. Sample values include Episode, Season, and Tracks. A complete list of values follows this table.
* ResponseGroup - _string_ (Optional) Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas.
* returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
* ReviewSort - _string_ (Optional) Sorts reviews based on the value of the parameter. '-HelpfulVotes', 'HelpfulVotes', '-OverallRating', 'OverallRating', 'Rank', '-Rank', '-SubmissionDate', 'SubmissionDate'.
* SearchIndex - _string_ (Optional) The product category to search. Many ItemSearch parameters are valid with only specific values of SearchIndex.
* Sort - _string_ (Optional) Means by which the items in the response are ordered.
* Style - _string_ (Optional) Controls the format of the data returned in Amazon Associates Web Service responses. Set this parameter to "XML," the default, to generate a pure XML response. Set this parameter to the URL of an XSLT stylesheet to have Amazon Associates Web Service transform the XML response. See ContentType.