getresponse/sdk-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

getresponse/sdk-php

Composer 安装命令:

composer require getresponse/sdk-php

包简介

SDK for all public GetResponse products

README 文档

README

This document covers the basics of using SDK for PHP. For detailed documentation, please refer to the resources in docs directory:

Read more about the API in GetResponse API Docs and GetResponse API Reference.

Requirements

  • PHP 7.3+

  • cURL

  • Composer or git

SDK installation

Using Composer

composer require getresponse/sdk-php

See https://getcomposer.org for details.

Using git

We recommend the composer installation. However, you can get SDK PHP by cloning the git project:


git clone https://github.com/GetResponse/sdk-php.git

The releases are available on GitHub: https://github.com/GetResponse/sdk-php/releases

Creating client

To create a GetResponse client object, use:

<?php

use Getresponse\Sdk\GetresponseClientFactory;

$client = GetresponseClientFactory::createWithApiKey('my_api_key');

API_KEY should be defined in the environment variable. You should define it in the global environment, command line of the script, or by putenv() during the startup of your framework (where do I find the API Key?)

Please see the GetResponseClientFactory class from PHP SDK for other factories.

Enterprise users

For the Enterprise environment please use one of the Enterprise factories, e.g.:

<?php

use Getresponse\Sdk\GetresponseClientFactory;

$client = GetresponseClientFactory::createEnterprisePLWithApiKey('my_api_key', 'myexampledomain.com');

or:

<?php

use Getresponse\Sdk\GetresponseClientFactory;

$client = GetresponseClientFactory::createEnterpriseUSWithApiKey('my_api_key', 'myexampledomain.com');

You have to provide the domain registered in GetResponse. Please see the GetResponseClientFactory class from Getresponse\Sdk namespace for other functions and other authorization methods.

Processing single and multiple operations

To send a single operation (request), you have to create an operation object (possibly with params) and send by defined client.

Example:

<?php

use Getresponse\Sdk\Operation\Campaigns\GetCampaigns\GetCampaigns; 

$campaignsOperation = new GetCampaigns();
$response = $client->call($campaignsOperation);

As a result, you will get a response object.

You can send multiple operations with one request. This will speed up operations with parallel processing. Please note that throttling limits will apply (read more in API limits and throttling documentation).

<?php

$operationsArray = array($operation1, $operation2, $operation3);
$responsesCollection = $client->callMany($operationsArray);

As a result, you will get a collection of responses. The responses are in the same order as the operations in an array.

Handling responses

To get a response, call:

<?php

$response = $client->call($campaignsOperation);

Checking response status

To determine if a response was successful, use:

<?php

$response->isSuccess();

To get HTTP status of response, use:

<?php

$response->getResponse()->getStatusCode();

Response data

The response is compatible with PSR-7.

Examples:

To get the data from response (as array):

<?php

$response->getData();

To get unprocessed data, from a response (in a serialized JSON format):

<?php

$response->getResponse()->getBody()->getContents();

To get the response size:

<?php

$response->getResponse()->getBody()->getSize();

To get the pagination data:

<?php

$response->isPaginated();

$response->getPaginationValues();

getresponse/sdk-php 适用场景与选型建议

getresponse/sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 953.01k 次下载、GitHub Stars 达 30, 最近一次更新时间为 2019 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 getresponse/sdk-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 getresponse/sdk-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 getresponse/sdk-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 30
  • Watchers: 8
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-15