承接 downshiftorg/wp-http 相关项目开发

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

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

downshiftorg/wp-http

最新稳定版本:2.0.0

Composer 安装命令:

composer require downshiftorg/wp-http

包简介

A psr7-ish, Guzzle-ish, set of request/response classes for WordPress.

README 文档

README

Provides a consistent, object-oriented API for making HTTP requests and receiving responses in the WordPress ecosystem. Provides a thin wrapper around the WP_Http class and then normalizes the return values of the internal WP_Http::request method to return a Psr7-ish, Guzzle-ish, modern-ish Response object, which does not exist in WordPress.

Usage

<?php

use DownShift\WordPress\Http\Request;

$request  = new Request();
$response = $request->get('http://api.yolo.com/status');

$response->getStatusCode(); // (int)    200
$response->getBody();       // (string) '{"msg": "You only live once!"}'
$response->json();          // (array)  ['msg' => 'You only live once!']

You can also send post requests with x-www-form-urlencoded data like so:

$request->post('http://api.yolo.com/neckbeard', ['foo' => 'bar']);

It also provides a convenience method for posting json data, setting the appropriate Content-Type headers for you and json_encoding the data passed:

$request->postJson('http://api.yolo.com/neckbeard', [
    'foo' => 'bar',
    'jim' => 'jam',
]);

Installation

Install the latest version with

$ composer require downshiftorg/wp-http

Tests

$ vendor/bin/phpunit

统计信息

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

GitHub 信息

  • Stars: 38
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-15