-- HikaShop version -- : 3.2.0
-- Joomla version -- : 3.8.1
-- PHP version -- : 7.0.21
-- Browser(s) name and version -- : Firefox 7.0.21
Hi!
I am currently on the way of creating a plugin for handling the interaction between Hikashop on Joomla! and another service located on a different site. For this, I thought it would be cleaner to create a kind of Rest API by a plugin, rather than by an external script like i previously used to do for other plugins in Joomla!.
After a little search, i found your pask work:
HikAPI
, and because it looked quite simple, i choosed to give it a try. It was not fully functional as it was, but actually with 2 minor fixes, it works not bad (see end of message for the fixes).
But there are 2 things that puzzle me a little: when i displayed
in "hikapihelper.php" for a check, it came with almost 50 already declared urls, that really look like there was already a full API declared. To begin with, i have no idea where these values come from, they are already present when i do the display in the first line of the class __construct. Here is a small example of these values:
["/products/:id"]=>
array(2) {
["ctrl"]=>
string(18) "helper.api-product"
["options"]=>
array(1) {
["pagination"]=>
bool(true)
}
}
["/products"]=>
string(11) "/products/0"
...
Now there are 2 problems with this, the first is that these urls are not working currently. I tried to mess a little with what's inside the "ctrl" field to try to load something, but I couldn't make it work. The second problem is less important, just that the system doesn't allow me to redeclare these urls. If i want to implement it, i have to use another url.
I know that this project is a bit old, probably left to die, but with very few advices to solve these problems, it could be useful and i would probably gain lots of time.. what i would like to know:
_where do all these already declared urls come from, and were they intended to be functional?
_is there a quick fix i could do to make them work, if they were intended to work? It might be coming from a little change in HikaShop, i can do the fixes if I have little advices on this.
Thanks!
FOR THE FIXES:
_hikapihelper.php line 253: removed the reference here, as it caused all newly declared url to take the "ctrl" value from the last url declaration, caused by a reference chain that makes all "ctrl" fields point to the same value:
becomes
_hikapi.php line 82: "$base" comes empty when the joomla site is located in the root of the server, causing "strpos" to fail:
if(strpos($url, $base) !== 0)
becomes
if(!empty($base) && strpos($url, $base) !== 0)
_test.php: for the function "processRequest", the $url comes as declared in the first array (params are not removed). Instead of doing
you have to do
like declared in the array