承接 soltancode/send-request 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

soltancode/send-request

最新稳定版本:v2.0.0

Composer 安装命令:

composer require soltancode/send-request

包简介

Simple package for Laravel that makes it easy to send HTTP requests and integrate with web APIs.

README 文档

README

Simple package for Laravel Framework that makes it easy to send HTTP requests and integrate with web APIs.

Packagist Version Packagist Stars Packagist Downloads Packagist PHP Version Support Packagist License

Installation

composer require soltancode/send-request

Usage

If you use it as class (facade), import this:

use Soltancode\SendRequest\Facades\SendRequest;

GET Request:

// $baseUrl = "https://dummyjson.com";
// $service = "/products/1";

# Using as class:
SendRequest::get($baseUrl, $service);

# Using as helper:
sendRequest()->get($baseUrl, $service)

GET Request with params:

// $baseUrl = "https://dummyjson.com";
// $service = "/products/1";
// $params  = [
//     'q' => 'phone'
// ];

# Using as class:
SendRequest::get($baseUrl, $service, $params); # https://dummyjson.com/products/search?q=phone

# Using as helper:
sendRequest()->get($baseUrl, $service, $params); # https://dummyjson.com/products/search?q=phone

POST Request with params:

// $baseUrl = "https://api.example.com";
// $service = "/login";

# Using as class:
SendRequest::post($baseUrl, $service, [
    'username' => 'myusername',
    'password' => 'mypassword'
]);

# Using as helper:
sendRequest()->post($baseUrl, $service, [
    'username' => 'myusername',
    'password' => 'mypassword'
]);

PUT Request with params:

// $baseUrl = "https://api.example.com";
// $service = "/users/1";

# Using as class:
SendRequest::put($baseUrl, $service, [
    'first_name' => 'John',
    'last_name' => 'Doe'
]);

# Using as helper:
sendRequest()->put($baseUrl, $service, [
    'first_name' => 'John',
    'last_name' => 'Doe'
]);

PATCH Request with params:

// $baseUrl = "https://api.example.com";
// $service = "/users/1";

# Using as class:
SendRequest::patch($baseUrl, $service, [
    'first_name' => 'John'
]);

# Using as helper:
sendRequest()->patch($baseUrl, $service, [
    'first_name' => 'John'
]);

DELETE Request with params:

// $baseUrl = "https://api.example.com";
// $service = "/users";

# Using as class:
SendRequest::delete($baseUrl, $service, [
    'id' => 'John'
]);

# Using as helper:
sendRequest()->delete($baseUrl, $service, [
    'id' => 'John'
]);

Timeout

The timeout method may be used to specify the maximum number of seconds to wait for a response:

$response = sendRequest()->timeout(3)->post(/* ... */);

Other Packages

ReturnResponse - It's a return helper for showing standard json responses.

Contributing

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

Please make sure to update tests as appropriate.

License

MIT

统计信息

  • 总下载量: 2.55k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固