You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
4) Install the required Zend packages, ZendOAuth and ZendRest:
28
75
To do so, add the "repositories" and "require" sections in the composer.json file so the file looks
29
76
as follows:
30
-
````
31
-
{
32
-
"name": "",
33
-
"authors": [
77
+
```json
34
78
{
35
-
"name": "",
36
-
"email": ""
79
+
"name": "",
80
+
"authors": [
81
+
{
82
+
"name": "",
83
+
"email": ""
84
+
}
85
+
],
86
+
"repositories": [
87
+
{
88
+
"type": "composer",
89
+
"url": "https://packages.zendframework.com/"
90
+
}
91
+
],
92
+
"require": {
93
+
"zendframework/zendoauth": "2.0.*",
94
+
"zendframework/zendrest": "2.0.*"
95
+
}
37
96
}
38
-
],
97
+
```
39
98
40
-
"repositories": [
41
-
{
42
-
"type": "composer",
43
-
"url": "https://packages.zendframework.com/"
44
-
}
45
-
],
46
-
"require": {
47
-
"zendframework/zendoauth": "2.0.*",
48
-
"zendframework/zendrest": "2.0.*"
49
-
}
50
-
}
51
-
````
52
99
5) Run the command "php composer.phar install" to install the packages and their dependencies.
53
100
6) Set include_path:
54
101
* Method 1: Navigate to /private/etc/php.ini and set include_path to the paths to the Zend Framework under the ".../library/" directory and to the newly installed packages under the ".../vendor/" directory. The "vendor" folder should appear in your working directory after installing the packages with composer.
* Method 2: Alternatively, you can create a file called 'set_path.php' and set your paths there. If you chose to set the path using this option, the file set_path.php should look like:
** If you use this option make sure to create the file in the same folder as the folder which contains the OX3_API_Client2.php file. Also make sure to require the file by adding the line "require_once 'set_path.php'; " to the top of the OX3_Api_Client2.php file.
68
115
69
116
#Authentication/Example Scripts
70
117
Add this to your code to authenticate with Oauth:
71
-
````
118
+
```injectablephp
72
119
<?php
73
120
// If using Zend Framework 1
74
121
require_once 'OX3_Api_Client.php';
75
122
// if Using Zend Framework 2
76
123
require_once 'OX3_Api_Client2.php';
124
+
// if using the composer autoloader with the namespaced client
$client = new OX3_API_Client($uri, $email, $password, $key, $secret, $realm);
87
136
// if Using Zend Framework 2
88
-
$client = new OX3_API_Client2($uri, $email, $password, $key, $secret, $realm);
137
+
$client = new OX3_API_Client2($uri, $email, $password, $key, $secret, $realm);
138
+
// if using the new class
139
+
$client = new \OpenX\PlatformAPI\OXApiClient($uri, $email, $password, $key, $secret, $realm);
89
140
?>
90
141
````
91
142
** Note that when running the example scripts, OX3_Api_Client.php/OX3_Api_Client2.php must be in the same folder as the script. Also note that the example scripts contain some user configurable variables (besides the authentication section), which are described at the top of the scripts.
92
143
93
144
#Usage
94
-
* To see the results in a friendly format on the command line, use the functions json_Decode, getBody, and print_r.
95
-
Ex) $result = $client->get('/account');
96
-
print_r(json_decode($result->getBody(), true));
145
+
* To see the results in a friendly format on the command line, use the functions json_decode, getBody, and print_r.
146
+
Ex.:
147
+
148
+
$result = $client->get('/account');
149
+
print_r(json_decode($result->getBody(), true));
97
150
98
151
**GET REQUESTS:**
99
152
* To get all current objects of a certain type, use the following request:
100
-
````
153
+
```injectablephp
101
154
$result = $client->get('/"object_type"');
102
-
Ex) $result = $client->get('/account');
103
-
````
155
+
// Example:
156
+
$result = $client->get('/account');
157
+
```
104
158
105
159
* To get the object(s) with a specific value for some attribute(s), pass in the value of the desired attribute as an array along with the path:
106
-
````
160
+
```injectablephp
107
161
$query = array("attribute"=>"value");
108
-
$result = $client->get('/object_type', $query')
109
-
Ex) $query1 = array('name'=>'OpenX');
162
+
$result = $client->get('/object_type', $query)
163
+
// Example:
164
+
$query1 = array('name'=>'OpenX');
110
165
result1 = $client->get('/account', $query1);
111
-
--> Returns the account(s) with the name OpenX
112
-
````
166
+
// --> Returns the account(s) with the name OpenX
167
+
```
113
168
114
169
* Many fields have multiple options for what value they can take on. To see these options, use the following request:
0 commit comments