requester
v1.5
Get, Post, Put, Patch, 요청 삭제 보내기 요청
간단한 배열로 매개 변수를 보냅니다
간단한 배열로 헤더를 보냅니다
자동 로깅을 요청합니다
오류 로거
응답을 기다리지 않고 요청을 보냅니다
composer require arashabedii/requester
# to enable request logging just pass $logger=true to send method
Request::send([string] url, [array] or [string] or [file context] params, [string] request type , [array] headers,[bool] logger);
require 'vendor/autoload.php';
GET 요청을 보내십시오
<?php
use ArashAbedii Request ;
require ' ./vendor/autoload.php ' ;
#------------------------------SIMPLE GET REQUEST---------------------------
$ url = " https://reqres.in/api/users " ;
$ method = ' GET ' ;
$ params =[
' delay ' => 1 ,
];
$ headers =[
' Content-Type ' => ' application/json ' ,
];
$ logger = true ; //enable or diable logging requests
$ response =Request:: send ( $ url , $ params , $ method , $ headers , $ logger );
//show headers
echo $ response -> headers ;
//show response body
echo $ response -> body ; 게시물 요청을 보냅니다
<?php
use ArashAbedii Request ;
require ' ./vendor/autoload.php ' ;
#------------------------------SIMPLE POST REQUEST---------------------------
$ url = " https://reqres.in/api/users " ;
$ method = ' POST ' ;
$ params =[
' name ' => ' myname ' ,
' job ' => ' myjob '
];
$ headers =[
' Content-Type ' => ' application/json ' ,
];
$ logger = false ; //enable or diable logging requests
$ response =Request:: send ( $ url , $ params , $ method , $ headers , $ logger );
//show headers
echo $ response -> headers ;
//show response body
echo $ response -> body ; 풋 요청을 보내십시오
<?php
use ArashAbedii Request ;
require ' ./vendor/autoload.php ' ;
#------------------------------SIMPLE PUT REQUEST---------------------------
$ url = " https://reqres.in/api/users/2 " ;
$ method = ' PUT ' ;
$ params =[
' name ' => ' myname2 ' ,
' job ' => ' myjob2 '
];
$ headers =[
' Content-Type ' => ' application/json ' ,
];
$ logger = false ; //enable or diable logging requests
$ response =Request:: send ( $ url , $ params , $ method , $ headers , $ logger );
//show headers
echo $ response -> headers ;
//show response body
echo $ response -> body ; 패치 요청을 보내십시오
<?php
use ArashAbedii Request ;
require ' ./vendor/autoload.php ' ;
#------------------------------SIMPLE PATCH REQUEST---------------------------
$ url = " https://reqres.in/api/users/2 " ;
$ method = ' PATCH ' ;
$ params =[
' name ' => ' myname2 ' ,
' job ' => ' myjob2 '
];
$ headers =[
' Content-Type ' => ' application/json ' ,
];
$ logger = false ; //enable or diable logging requests
$ response =Request:: send ( $ url , $ params , $ method , $ headers , $ logger );
//show headers
echo $ response -> headers ;
//show response body
echo $ response -> body ; 삭제 요청을 보내십시오
<?php
use ArashAbedii Request ;
require ' ./vendor/autoload.php ' ;
#------------------------------SIMPLE DELETE REQUEST---------------------------
$ url = " https://reqres.in/api/users/2 " ;
$ method = ' DELETE ' ;
$ params =[
//no params or your params
];
$ headers =[
' Content-Type ' => ' application/json ' ,
];
$ logger = true ; //enable or diable logging requests
$ response =Request:: send ( $ url , $ params , $ method , $ headers , $ logger );
//show headers
echo $ response -> headers ;
//show response body
echo $ response -> body ;