PHP code example of ienaga / simple-api-client

1. Go to this page and download the library: Download ienaga/simple-api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ienaga / simple-api-client example snippets


$client = new \SimpleApi\Client();
$json = $client
    ->setEndPoint("https://search-****.ap-northeast-1.es.amazonaws.com")
    ->setPath("/index_name/type_name/_search?q=user:kimchy")
    ->send();

$client = new \SimpleApi\Client();
$json = $client
    ->addHeader("Authorization", "key=XXXXXXX")
    ->setEndPoint("https://fcm.googleapis.com/fcm/send")
    ->setMethod("POST")
    ->add("to", "INSTANCE_ID")
    ->add("priority", "high")
    ->add("content_available", true)
    ->add("notification", [
        "title" => "title", 
        "body"  => "body", 
        "badge" => 1
    ])
    ->send();

$client = new \SimpleApi\Client();
$json = $client
    ->setEndPoint("https://search-****.ap-northeast-1.es.amazonaws.com")
    ->setPath("/index_name/type_name")
    ->setMethod("PUT")
    ->add("status", 2)
    ->send();

$client = new \SimpleApi\Client();
$json = $client
    ->setEndPoint("https://search-****.ap-northeast-1.es.amazonaws.com")
    ->setPath("/index_name")
    ->setMethod("DELETE")
    ->send();