承接 wpcs/php-api-wrapper 相关项目开发

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

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

wpcs/php-api-wrapper

Composer 安装命令:

composer require wpcs/php-api-wrapper

包简介

A PHP API wrapper to easily communicate with the WPCS.io API.

README 文档

README

A PHP API wrapper to easily communicate with the WPCS.io API.

Authentication

In order to use the package, you need to authenticate with the WPCS API. You can create an API key/secret pair in the console to use for this wrapper.

There are two ways to authenticate the requests with this package: using constants or the builder functions.

Configuring authentication with builder functions

There are three functions to use to authenticate your requests: setRegion(string $region), setApiKey(string $key) and setApiSecret(string $secret)

Example:

$request = new \WPCS\API\GetTenantsRequest();
$response = $request
    ->setRegion('us1') // Or eu1, depending on your region.
    ->setApiKey('an-api-key') // The API Key you retrieved from the console
    ->setApiSecret('an-api-secret') // The API Secret you retrieved from the console
    ->send();

This allows you to use your own secrets management.

Constants

If you are using, for example, WordPress, it is common to place secrets in the wp-config.php file as constants. You can do this for the wrapper as well. The three required constants are WPCS_API_REGION, WPCS_API_KEY and WPCS_API_SECRET. When these are defined, you do not need to use the builder functions to setup authentication.

Example:

define('WPCS_API_REGION', 'us1'); // Or eu1, depending on your region.
define('WPCS_API_KEY', 'an-api-key'); // The API Key you retrieved from the console
define('WPCS_API_SECRET', 'an-api-secret'); // The API Secret you retrieved from the console

// No need to set the region, API key and secret using functions now
$request = new \WPCS\API\GetTenantsRequest();
$response = $request->send();

Example usage

A request to the WPCS API to create a new version might look like this (when not using the constants to authenticate). This request will create a version, based on the last snapshot of the current production version in WPCS in a product that resides in the US1 region.

$request = new \WPCS\API\CreateVersionRequest();
$response = $request
    ->setRegion('us1')
    ->setApiKey('an-api-key')
    ->setApiSecret('an-api-secret')
    ->setName('v2.0.0')
    ->setWordPressVersion('6.0')
    ->setPhpVersion('7.4')
    ->send();

统计信息

  • 总下载量: 74
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固