GithubHelp home page GithubHelp logo

custom-endpoints's Introduction

Custom Endpoints

Simple endpoint to receive data, process it, and send a response

After installing the plugin on your marketplace, the URL of the endpoint will depend on the folder in which you stored the PHP script.

In this repo, the script are found in the user folder. So the URL of the custom API in simple_POST_endpoint.php will take this format

https://{{your-marketplace}}.arcadier.io/user/plugins{{plugin-ID}}/simple_POST_endpoint.php

The name of the file can be anything you choose.

To test this particular endpoint (simple_POST_endpoint.php), Postman can be used.

  • Method: POST
  • URL: https://{{your-marketplace}}.arcadier.io/user/plugins{{plugin-ID}}/simple_POST_endpoint.php
  • Request Body:
{
    "message": x
}

where xis an integer.

This endpoint simply receives an integere and multiplies it by 2.

include 'callAPI.php';
	
$contentBodyJson = file_get_contents('php://input');
$content = json_decode($contentBodyJson, true);

echo $content['message']*2;

Endpoint with multiple methods

The second file simple_general_endpoint.php does a bit more than simply receiving data.

The API expects a required parameter method in the request body:

{
    "method": 'GET',
    "message": x
}

According to the script in simple_general_endpoint.php, it expects one of the four methods: GET, POST, PUT, and delete.

if($content['method'] == 'GET'){
        //do something with another API
}

if($content['method'] == 'POST'){
    // do something else with another API
}

if($content['method'] == 'PUT'){
    // do something else with another API
}

if($content['method'] == 'delete'){
    // do something else with another API
}

URL of endpoints found in the admin folder

If any of the PHP scripts were found in the admin folder, the URL would be like this instead:

https://{{your-marketplace}}.arcadier.io/admin/plugins{{plugin-ID}}/simple_POST_endpoint.php

custom-endpoints's People

Contributors

tanoojoy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.