HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast usage.

Overview

HttpRequestor from Patienceman

HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast usage.

Installation

Installing the package doesn't require much requirement except to paste the following command in the laravel terminal, and you're good to go.

  composer require patienceman/httprequestor

Usage

To use HTTP Requestor u need to call HttpRequest class, But before everything you need to publish the config file for "HTTP requestor", Just run!

php artisan vendor:publish --tag=HttpConfigs

Let's take the example with it and see the simplicity

  $http = HttpRequest::server('https://commandement.com');

So!, now you can make requests with all standard methods. There are two ways this package is useful, by requesting an access token to the server or by sending a normal request

let's take the example of requesting access token

  $http = HttpRequest::server('https://commandement.com');

  $http->buildHttpQuery([
      'grant_type' => 'client_credentials',
      'client_id' => config('services.custom.client_id'),
      'client_secret' => config('services.custom.client_secret'),
      'scope' => config('services.custom.scope)
  ]);

  return $http->requestToken('/oauth/token');

So now we are able to request an access tokens.

Let also take the example of a normally api request with standard HTTP methods

  $http = HttpRequest::server('https://commandement.com');

  $http->withHeaders([
      'Authorization' => $accessToken,
      'Accept' => 'application/json',
  ]);
  
  $http->withData([
    'name' => 'moses',
    'location' => 'mountain-sinai',
    'command' => 'navigate islaels'
  ]);
  
  $http->request('POST', '/api/sync-movement')

  return $http->then(function($response, $error) {
      return $response->last_update_at;
  });

Fantastic right! and super cool!

So now on Moses are able to make a super request to our commandment server!,

This package also contains the HttpResponse Helper class, which support your JSON response to remove all null value, on the go! To use it, u need just one class bash HttpResponse

let's take an example with it and see how it works!

  function httpJsonResponse(?string $message, $data = null, array $with, int $code = 200): JsonResponse {
      $response = HttpResponse::create(array_merge([
          'success' => ($code > 199 && $code < 300) ? true : false,
          'data' => $data,
          'message' => $message
      ], $with));

      return response()->json($response->extract(), $code);
  }

And whenever one of the passed parameters is null, the HttpResponse deletes it from the parameters, soon or later we're going to another way of making it optional.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

You might also like...
Facebook GraphQL for Laravel 5. It supports Relay, eloquent models, validation and GraphiQL.

Laravel GraphQL This package is no longuer maintained. Please use rebing/graphql-laravel or other Laravel GraphQL packages Use Facebook GraphQL with L

This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via PHP
This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via PHP

This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via PHP

PHP package providing easy and fast access to Twitter API V2.

Twitter API V2 is a PHP package that provides an easy and fast access to Twitter REST API for Version 2 endpoints.

oursms.app client library that allows you to send SMS

Oursms laravel client https://oursms.app client library that allows you to send SMS Installation Install oursms client with composer composer requir

A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP
A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP

A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP. Including adding reviews to a store's products. It is used to import and export reviews through the API. This is the official package built and developed by A2Reviews, Inc.

⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.
⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.

Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC. This project is a work-in-progress. Code and docume

A tool for sending fast and managed messages to Telegram bot users

👋🏻 HiToAll A tool for sending fast and managed messages to Telegram bot users About In some telegram bots programmed with php language, if there are

A simple PHP API to make working with SharePoint lists easy.

PHP SharePoint Lists API The PHP SharePoint Lists API is designed to make working with SharePoint Lists in PHP a less painful developer experience. Ra

It’s a bot using simple feature - jangan keseringan make (haram cok)

It’s a bot using simple feature - jangan keseringan make (haram cok)

Releases(v1.0.0)
  • v1.0.0(Aug 23, 2022)

    HttpRequestor from Patienceman

    HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast usage.

    Installation

    Installing the package doesn't require much requirement except to paste the following command in the laravel terminal, and you're good to go.

      composer require patienceman/httprequestor
    

    Usage

    To use HTTP Requestor u need to call HttpRequest class, But before everything you need to publish the config file for "HTTP requestor", Just run!

    php artisan vendor:publish --tag=HttpConfigs
    

    Let's take the example with it and see the simplicity

      $http = HttpRequest::server('https://commandement.com');
    

    So!, now you can make requests with all standard methods. There are two ways this package is useful, by requesting an access token to the server or by sending a normal request

    let's take the example of requesting access token

      $http = HttpRequest::server('https://commandement.com');
    
      $http->buildHttpQuery([
          'grant_type' => 'client_credentials',
          'client_id' => config('services.custom.client_id'),
          'client_secret' => config('services.custom.client_secret'),
          'scope' => config('services.custom.scope)
      ]);
    
      return $http->requestToken('/oauth/token');
    

    So now we are able to request an access tokens.

    Let also take the example of a normally api request with standard HTTP methods

      $http = HttpRequest::server('https://commandement.com');
    
      $http->withHeaders([
          'Authorization' => $accessToken,
          'Accept' => 'application/json',
      ]);
      
      $http->withData([
        'name' => 'moses',
        'location' => 'mountain-sinai',
        'command' => 'navigate islaels'
      ]);
      
      $http->request('POST', '/api/sync-movement')
    
      return $http->then(function($response, $error) {
          return $response->last_update_at;
      });
    

    Fantastic right! and super cool!

    So now on Moses are able to make a super request to our commandment server!,

    This package also contains the HttpResponse Helper class, which support your JSON response to remove all null value, on the go! To use it, u need just one class bash HttpResponse

    let's take an example with it and see how it works!

      function httpJsonResponse(?string $message, $data = null, array $with, int $code = 200): JsonResponse {
          $response = HttpResponse::create(array_merge([
              'success' => ($code > 199 && $code < 300) ? true : false,
              'data' => $data,
              'message' => $message
          ], $with));
    
          return response()->json($response->extract(), $code);
      }
    

    And whenever one of the passed parameters is null, the HttpResponse deletes it from the parameters, soon or later we're going to another way of making it optional.

    Contributing

    Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

    License

    MIT

    Source code(tar.gz)
    Source code(zip)
Owner
Manirabona Patience
“To be yourself in a world that is constantly trying to make you something else is the greatest accomplishment.”
Manirabona Patience
A PHP package for handling client requests, sending response, database CRUD operations, among others, easily

Zam Zam helps to receive and process client request(s), return response to client with appropriate header and database CRUD operation for a more robus

SirMekus 3 Dec 31, 2022
Adds a specific header to every response to disable Google's usage of your site in it's FLoC tracking method.

Go Unfloc Yourself Description A bundle for Symfony 5 that adds a Permissions-Policy header in all the responses to prevent the use of new Google's "F

(infinite) loophp 3 Feb 25, 2022
Telegram API made for php (Simple usage)

Telegram Telegram API made for php (Simple usage) How to use? Download the project & place Telegram folder tp your project directory (For example i se

null 0 Apr 4, 2022
json-rpc client base on http

laravel JSON-RPC客户端(Http协议) 本项目是基于JSON-RPC的服务端端实现的rpc客户端 server端见:https://sajya.github.io/ 初始化 发布 php artisan vendor:publish --provider="Ze\JsonRpcCli

Zeee 2 Nov 19, 2021
json-rpc client base on http

laravel JSON-RPC客户端(Http协议) 本项目是基于JSON-RPC的服务端端实现的rpc客户端 server端见:https://sajya.github.io/ 初始化 1.发布 php artisan vendor:publish --provider="Ze\JsonRPCC

null 2 Nov 19, 2021
SendGrid's PHP HTTP Client for calling APIs

Quickly and easily access any RESTful or RESTful-like API. If you are looking for the SendGrid API client library, please see this repo. Announcements

Twilio SendGrid 119 Nov 25, 2022
Use rmccue/requests as a PSR-18 HTTP client

WordPress/Requests PSR-18 Adapter Use WordPress/Requests as a PSR-18 HTTP client adapter. Requires PHP 7.1+ Why? Requests is a HTTP library written in

Artur Weigandt 5 Dec 15, 2022
OpenAI API Client is a component-oriented, extensible client library for the OpenAI API. It's designed to be faster and more memory efficient than traditional PHP libraries.

OpenAI API Client in PHP (community-maintained) This library is a component-oriented, extensible client library for the OpenAI API. It's designed to b

Mounir R'Quiba 6 Jun 14, 2023
Google-api-php-client - A PHP client library for accessing Google APIs

Google APIs Client Library for PHP Reference Docs https://googleapis.github.io/google-api-php-client/main/ License Apache 2.0 The Google API Client Li

Google APIs 8.4k Dec 30, 2022
PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

Sergey Bykov 63 Feb 14, 2022