承接 sendpulse/market-rest-api 相关项目开发

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

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

sendpulse/market-rest-api

最新稳定版本:0.1.1

Composer 安装命令:

composer require sendpulse/market-rest-api

包简介

Sendpulse Market REST API client library

README 文档

README


SendPulse Market REST client library


API Documentation · Developer Documentation

A simple SendPulse Market REST client library and example for PHP.

Requirements

  • php: >=7.1.0
  • ext-json: *
  • ext-curl: *

Installation

Via Composer:

composer require sendpulse/market-rest-api

Example

<?php

require 'vendor/autoload.php';

use Sendpulse\MarketRestApi\Client;
use Sendpulse\MarketRestApi\Storage\FileStorage;
use Sendpulse\MarketRestApi\Exception\ClientException;


$appId = '9b0f2f98-d75f-4562-887e-2b79bc8a1eee';
$appSecret = '0d028163-9c84-40e4-8508-f4927badf735';
$requestParamCode = '5869d2b87b132aa1372242f223e5381e'; //get code into request


/**
 * Get client credentials by login request
 * @link https://sendpulse.com/knowledge-base/app-directory/developers/login-flow
 */
try {
    $userCredentials = (new Client())
        ->getClientCredentialsByCode($requestParamCode, $appId, $appSecret);

    var_dump($userCredentials);
} catch (ClientException $e) {
    var_dump([
        'message' => $e->getMessage(),
        'httpCode' => $e->getCode(),
        'responseBody' => $e->getResponseBody(),
        'headers' => $e->getHeaders(),
        'curlErrors' => $e->getCurlErrors(),
    ]);
}

/**
 * List user addressbooks by client credentials
 * @link https://sendpulse.ua/ru/integrations/api/bulk-email#lists
 */
try {
    $clientId = '';
    $clientSecret = '';

    $addressbooks = (new Client())
        ->setClientCredentials($clientId, $clientSecret, new FileStorage(''))
        ->get('addressbooks', [], true);

    var_dump($addressbooks);
} catch (ClientException $e) {
    var_dump([
        'message' => $e->getMessage(),
        'httpCode' => $e->getCode(),
        'responseBody' => $e->getResponseBody(),
        'headers' => $e->getHeaders(),
        'curlErrors' => $e->getCurlErrors(),
    ]);
}

/**
 * List user addressbooks by one flow
 * @link https://sendpulse.ua/ru/integrations/api/bulk-email#lists
 */
try {
    $client = new Client();
    $userCredentials = $client->getClientCredentialsByCode($requestParamCode, $appId, $appSecret);

    $addressbooks = $client->setClientCredentials(
        $userCredentials['client_id'],
        $userCredentials['client_secret'],
        new FileStorage('')
    )->get('addressbooks', [], true);

    var_dump($addressbooks);
} catch (ClientException $e) {
    var_dump([
        'message' => $e->getMessage(),
        'httpCode' => $e->getCode(),
        'responseBody' => $e->getResponseBody(),
        'headers' => $e->getHeaders(),
        'curlErrors' => $e->getCurlErrors(),
    ]);
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-02