Git Product home page Git Product logo

requests's Introduction

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

My Requests

Library Interface Requests use cURL, File Get Contents, SOAP Requests

Library use package: Curl, GuzzleHttp and nuSOAP

Version

  • V1.x, V2.x support all PHP version >=5.6
  • V3.x support all PHP version >=7.0

Installation

Manual install

Step 1: Save library to your project

cd /your/to/path
wget https://github.com/nguyenanhung/requests/archive/master.zip
unzip master.zip

Step 2: Init to Project

<?php 
require '/your/to/path/MyRequests.php';
use \nguyenanhung\MyRequests\MyRequests;

$requests = new MyRequests();

Install with composer

Step 1: Install package

composer require nguyenanhung/requests

Step 2: Init to Project

<?php 
require '/your/to/path/vendor/autoload.php';
use \nguyenanhung\MyRequests\MyRequests;
$requests = new MyRequests();

How to Use

Get Version of Library

<?php
require '/your/to/path/vendor/autoload.php';
use \nguyenanhung\MyRequests\MyRequests;
$requests = new MyRequests();

echo $requests->getVersion(); // Print: 1.0.14

Send Request

<?php
require '/your/to/path/vendor/autoload.php';
use nguyenanhung\MyRequests\MyRequests;

$debug                    = [
    'debugStatus'     => TRUE,
    'debugLoggerPath' => testLogPath()
];
$url                      = 'https://httpbin.org/';
$data                     = [
    'date'    => date('Y-m-d'),
    'service' => 'ME',
    'token'   => 'empty'
];
$method                   = 'GET';
$headers                  = [];
$options                  = [];
$request                  = new MyRequests();
$request->debugStatus     = TRUE;
$request->debugLoggerPath = '/your/to/path/save_log';
$request->__construct();
$request->setHeader($headers);
$request->setOptions($options);

echo $request->getVersion(); // Print: 0.1.3.4

$guzzlePhpRequest = $request->guzzlePhpRequest($url, $data, $method);
d($guzzlePhpRequest);

$curlRequest = $request->curlRequest($url, $data, $method);
d($curlRequest);

$sendRequest = $request->sendRequest($url, $data, $method);
d($sendRequest);

Send Request with File Get Contents

<?php
require '/your/to/path/vendor/autoload.php';
use nguyenanhung\MyRequests\GetContents;

// Test Data
$url    = 'https://httpbin.org/';
$data   = [
    'date'    => date('Y-m-d'),
    'service' => 'ME',
    'token'   => 'empty'
];
$method = 'GET';
// Let's Go
$content = new GetContents();
$content->setURL($url);
$content->setMethod($method);
$content->setData($data);
$content->sendRequest();

echo $content->getVersion(); // Print: 0.1.3.4

$response   = $content->response();
$getContent = $content->getContent();
$getError   = $content->getError();

d($response);
d($getContent);
d($getError);

Send Request with SOAP Request

<?php
require '/your/to/path/vendor/autoload.php';
use nguyenanhung\MyRequests\SoapRequest;

$soap                  = new SoapRequest();
$soap->debugStatus     = true;
$soap->debugLoggerPath = '/your/to/path/save_log';
$soap->__construct();
$soap->setEndpoint('url');
$soap->setCallFunction('function');
$soap->setData($data);
$result = $soap->clientRequestWsdl();

echo $soap->getVersion(); // Print: 0.1.3.4
d($result);

Contact

If any question & request, please contact following information

Name Email Skype Facebook
Hung Nguyen [email protected] nguyenanhung5891 @nguyenanhung

From Hanoi with Love <3

requests's People

Contributors

hungnguyenhp avatar nguyenanhung 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.