Celuran, I said it before but you truely are my Hero

Thanks!!
Ok so now I know how to pass the apiKey and get the following error:
Fatal error: Call to a member function verifyKey() on string in /customers/d/7/2/fairdea.com/httpd.www/api/barcode/MyAPI.class.php on line 16
which is expected since I do not have a Models class yet.
what does the following part mean?
Code: Select all
$APIKey = new Models\APIKey();
$User = new Models\User();
I do get the lines create new objects from the class Models but I cant figure out the \APIKey() or \User() part. I only made classes that you call like /../ new MyClass($str1, $str2);
In my codewindow I see the Models part turn yellow and the \APIKey() part remain black why i figure in the codezippet above there is a class Models and it somehow contain APIKey and User.. I tried to google what it means to call a class like new class\extension but I dont know what to search for..what its called or how it works so I cant find any info about this practice?
So far I "cheated and made 2 classes one for key and one for user to get it to work:
in myClass.php
Code: Select all
// Abstracted out for example
$APIKey = new ModelsAPI(); //new Models\APIKey();
$User = new ModelsUSER(); //new Models\User();
Code: Select all
class ModelsAPI {
public function verifyKey($key, $origin){
if($key == 'Test'){
return true;
} else {
return false;
}
}
}
class ModelsUSER {
public function verifyKey($token, $origin){
if($token == '1'){
return "PETER";
} elseif($token == '2') {
return "Thomas";
} else {
return false;
}
}
Some other questions:
how do I supply "token" to this API request anything i write after /?apiKey=Test seems to be interpret as apiKey so if i write /?apiKey=Test/?token=user1 the script will think I provided the apiKey Test/?token=user1 which is not equal to Test and the api will tell me i have the wrong apiKey.
The test function "example" uses GET method
Code: Select all
protected function example() {
if ($this->method == 'GET') {
return "Your name is " . $this->User->name;
} else {
return "Only accepts GET requests";
}
}
from what I understand when i type in browser
http://www.fairdea.com/api/barcode/example/?apiKey=Test
this is a GET method but how do I write a POST method to this API?
Say I have a function
Code: Select all
protected function test() {
if ($this->method == 'POST') {
return "Your name is " . $this->User->name;
} else {
return "Only accepts POST requests";
}
}
How would I call this in the browser?
http://www.fairdea.com/api/barcode/POST ... piKey=Test
Tells me POST is not an endpoint (since the endpoint is test which is moved one step to the left in the request).