Closed kumarg311 closed 7 years ago
Hi,
I assume that, you are installed api plugin and published it. To call api method you can use ajax call or using curl ( in case of php call ) or jHTTP(joomla) method, place url as given below in api call code.
Url format is as given below -
For - Access public resource file
http//[root address]/index.php?option=com_api&app=[plugin name]&resource=[plugin resource file name]&format=raw
For - Access private resource file
key = user authentication key generated by com_api component.
http//[root address]/index.php?option=com_api&app=[plugin name]&resource=[plugin resource file name]&format=raw&key=key
Hello @vishal22 @kumarg311, I am getting this as response for a test call: { "code": 400, "message": "Users API Plugin not found, Users is probably not installed" }
Any idea? Thanks!
Can you confirm if the users plugin is installed and published as well.
Thanks @coolbung, I can confirm it is installed and published. In case I disable the plugin a different message error is returned.
@coolbung Any news on this?
Can you share the request URL that you are using ?
I figured it out by reading the code. Turns out I have to implement the plugin so that it can find it under plugins/api. Right?
Thats right, the URL for any request should be
index.php?option=com_api&format=raw&app=
Can you explain what should I implement in these methods:
invoke negotiateContent fetchResource
?
I figured that ''fetchResource'' is the one who returns the JSON or XML, but what are the others for?
You don't need any of that. Take a look at the user resource in the user plugin - https://github.com/techjoomla/com_api-plugins/blob/master/users/users/users.php
You only need the post() and get() methods in the resource. These get triggered based on if your URL is being called via HTTP GET or POST.
Content negotiation is done by the framework, so you don't need any of those methods in your plugin.
Ok, now I can't get pass this message:
{"code":404,"message":"Json Resource not found in this API"}
json is the name of my resource. I have a file called json.php
I followed the example just like the users.php example
Ok. Got it working. It looks like the class names for the ApiResources have to follow a certain convention. Thanks! You've been very helpful!
i am yet to wrap my head around a simple way of making a method call....
i tried this url still getting error http://localhost/ptv/index.php?option=com_api&app=Com_K2&resource=&format=raw&key=key
You need to create a API plugin and resources within the plugin. If your API plugin for K2 has the plugin name as plgAPIK2, and then the resource class is K2ApiResourceItems
http://localhost/ptv/index.php?option=com_api&app=k2&resource=items&format=raw&key=key
You can refer the users plugin for the plugin & resource structure https://github.com/techjoomla/com_api-plugins/tree/master/users
On Fri, Apr 29, 2016 at 5:26 AM, Victor Chigozie Nwafor < notifications@github.com> wrote:
i am yet to wrap my head around a simple way of making a method call....
i tried this url still getting error
http://localhost/ptv/index.php?option=com_api&app=Com_K2&resource=&format=raw&key=key
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/techjoomla/com_api/issues/13#issuecomment-215596751
Thanks! Ashwin Date techjoomla.com http://techjoomla.com/?utm_source=email_signature&utm_medium=email&utm_campaign=ashwin | appcarvers.com http://appcarvers.com/?utm_source=email_signature&utm_medium=email&utm_campaign=ashwin | tekdi.net http://tekdi.net/?utm_source=email_signature&utm_medium=email&utm_campaign=ashwin @coolbung | @techjoomla | @appcarvers | @tekdinet
If it isn't broken, don't fix it!
Hi, I installed this component , but i confused that how to call api methods.
please show the calling url or url structure.
Thanks Gaurav