|
@@ -3,7 +3,7 @@ require "../lib/php_crud_api_transform.php";
|
3
|
3
|
|
4
|
4
|
$cookiejar = tempnam(sys_get_temp_dir(), 'cookiejar-');
|
5
|
5
|
|
6
|
|
-function call($method, $url, $data = false, $csrf = false) {
|
|
6
|
+function call($method, $url, $csrf = false, $data = false) {
|
7
|
7
|
global $cookiejar;
|
8
|
8
|
$ch = curl_init();
|
9
|
9
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
|
@@ -27,8 +27,8 @@ function call($method, $url, $data = false, $csrf = false) {
|
27
|
27
|
}
|
28
|
28
|
|
29
|
29
|
// in case you are using php-api-auth:
|
30
|
|
-$csrf = json_decode(call('POST','http://localhost/api.php/', 'username=admin&password=admin'));
|
31
|
|
-$response = call('GET','http://localhost/api.php/posts?include=categories,tags,comments&filter=id,eq,1', false, $csrf);
|
|
30
|
+$csrf = json_decode(call('POST','http://localhost/api.php/', false, 'username=admin&password=admin'));
|
|
31
|
+$response = call('GET','http://localhost/api.php/posts?include=categories,tags,comments&filter=id,eq,1', $csrf);
|
32
|
32
|
|
33
|
33
|
unlink($cookiejar);
|
34
|
34
|
|