https://github.com/opensource-socialnetwork/extendapi
A example to utilize the OSSN RESTful API, it extends the existing API feature and add custom method to system
https://github.com/opensource-socialnetwork/extendapi
Last synced: 6 months ago
JSON representation
A example to utilize the OSSN RESTful API, it extends the existing API feature and add custom method to system
- Host: GitHub
- URL: https://github.com/opensource-socialnetwork/extendapi
- Owner: opensource-socialnetwork
- Created: 2019-03-03T18:00:22.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-09-20T15:41:13.000Z (over 2 years ago)
- Last Synced: 2025-05-12T18:47:08.109Z (8 months ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 8
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ExtendAPI
A example to utilize the OSSN RESTful API, it extends the existing API feature and add custom method to system
This component add custom api method (my_custom_end_point) that can be called following way :
CURL https://www.mywebsite.com/api/v1.0/my_custom_end_point?api_key_token=
The output is simply the comparing two static variables and display api response.
You can edit this component and add more methods by simply adding below in function `my_custom_end_point_register` in file components/ExtendAPI/ossn_com.php
$methods['v1.0'][] = 'custom_method_second';
Once you added you need to create a file in `components/ExtendAPI/plugins/default/services/v1.0/custom_method_second.php`
## Set success and error response
To set success response use following :
$params['OssnServices']->successResponse("My message for success goes here");
For error:
$params['OssnServices']->throwError('200', "Error response here"); //don't change 200 error code, in case you want to have own error code , you may change it with your own custom error code.