PluginProbe
AliNext – WooCommerce Dropshipping Plugin for AliExpress / trunk
AliNext – WooCommerce Dropshipping Plugin for AliExpress vtrunk
ali2woo-lite / includes / libs / ae-php-sdk / iop / IopRequest.php

IopRequest.php in AliNext – WooCommerce Dropshipping Plugin for AliExpress trunk, at includes/libs/ae-php-sdk/iop/IopRequest.php

85 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class IopRequest
3 {
4 public $apiName;
5
6 public $headerParams = array();
7
8 public $udfParams = array();
9
10 public $fileParams = array();
11
12 public $httpMethod = 'POST';
13
14 public $simplify = 'false';
15
16 public $format = 'json';//支持TOP的xml
17
18
19
20 public function __construct($apiName,$httpMethod = 'POST')
21 {
22 $this->apiName = $apiName;
23 $this->httpMethod = $httpMethod;
24
25 if($this->startWith($apiName,"//"))
26 {
27 throw new Exception("api name is invalid. It should be start with /");
28 }
29 }
30
31
32 function addApiParam($key,$value)
33 {
34
35 if(!is_string($key))
36 {
37 throw new Exception("api param key should be string");
38 }
39
40 if(is_object($value))
41 {
42 $this->udfParams[$key] = json_decode($value);
43 }
44 else
45 {
46 $this->udfParams[$key] = $value;
47 }
48 }
49
50 function addFileParam($key,$content,$mimeType = 'application/octet-stream')
51 {
52 if(!is_string($key))
53 {
54 throw new Exception("api file param key should be string");
55 }
56
57 $file = array(
58 'type' => $mimeType,
59 'content' => $content,
60 'name' => $key
61 );
62 $this->fileParams[$key] = $file;
63 }
64
65 function addHttpHeaderParam($key,$value)
66 {
67 if(!is_string($key))
68 {
69 throw new Exception("http header param key should be string");
70 }
71
72 if(!is_string($value))
73 {
74 throw new Exception("http header param value should be string");
75 }
76
77 $this->headerParams[$key] = $value;
78 }
79
80 function startWith($str, $needle) {
81 return strpos($str, $needle) === 0;
82 }
83 }
84
85 ?>