Jump to content

Connecting to 3rd party REST API service endpoints


Go to solution Solved by bfarber,

Recommended Posts

Could you clarify what you're trying to achieve?

We have introduced a Webhook System in 4.5 which could be used for this, but right now it's limited to be used by 3rd party Applications, Plugins and our own Zapier integration.

This means, registered web hooks will be able to get a notification with the available data when a specific event happens (e.g. when a member registers, when a topi (or literally any content is created, edited or deleted ) 

Link to comment
Share on other sites

  • Solution

If you're trying to call a third party REST API, you would just use the built in HTTP libraries we leverage.

When I test connecting to our own built in REST API locally I use a test script like so typically

<?php

$apiKey = 'my-api-key';

require 'init.php';
\IPS\Dispatcher\External::i();

$response = \IPS\Http\Url::external( \IPS\Settings::i()->base_url . '/api/core/members/1' )
	->request()
	->login( $apiKey, '' )
	->get()
	->decodeJson();

var_dump($response);
exit;

 

Link to comment
Share on other sites

Thank you both, really appreciate the responses.

On 10/5/2020 at 5:29 PM, Daniel F said:

Could you clarify what you're trying to achieve?

Sure, I'm looking to communicate with Cloudflare, AWS REST API, and a couple of other 3rd party services to utilise data in widgets etc.  They usually give examples as Curl commands, but I wasn't sure how best to intergrate into IPS.

https://api.cloudflare.com/#getting-started-endpoints

Link to comment
Share on other sites

The heart of it from my answer is

$response = \IPS\Http\Url::external( \IPS\Settings::i()->base_url . '/api/core/members/1' )
	->request()
	->login( $apiKey, '' )
	->get()
	->decodeJson();

The framework will determine if curl is available and use it or fall back to sockets, and there are helper methods to do things like posting, logging in and so on.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...