Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If your site has an API, then suitable place to put is some controller in your application/controllers folder, that's how you can respond to the API calls from outside. Example:</p> <pre> class Api extends CI_Controller { //Your code goes here } </pre> <p>If you want to use another API that you want to get responses from, good practice would be to create class in application/libraries/Some_Api.php that will handle the requests and responses to the outside API, of course you will need to call it somewhere in your controllers, models, etc... depending on your needs.</p> <p><em><strong>EDIT</em></strong> Example for this would be:</p> <pre> class Myapi extends CI_Controller { public function __construct() { parent::__construct(); } //Here goes your function: public function api_call() { //Some params that Some_Api class will need (if needed of course) $params = array('url' => 'https://checkout.google.com', 'username' => 'your_username'); //Include the library require_once(APPPATH.'libraries/Some_Api.php'); //Create instance of it $api = new Some_Api($params); //Call the external API and collect the response. //In most cases the response is XML and you need to process it as you need it. $response = $api->call_some_api_method(); //Process the response here. //Save to database/file, send emails, do whatever you need to. } } </pre> <p>Please note that I have used some trivial examples just to explain how the process usually goes. Most of the work should be done in the Some_Api class. I hope this helps for you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload