caseyw/restorationmedia-php

一个简单的库,用于向Restoration Media添加数据

dev-master 2015-04-09 15:20 UTC

This package is auto-updated.

Last update: 2024-09-29 04:42:21 UTC


README

Build Status

一个小型项目,用于与Restoration Media接口。

需要有一个简单的方式来传递正确的数据,并知道响应是否正确。

$client = new GuzzleHttp\Client();

// Required API fields are constructor injected
$api = new \RestorationMedia\RestorationMediaApi(
    $client, 
    $pid, 
    $email, 
    $ipAddress, 
    $source, 
    $date, 
    $params // Optional fields as array
);

if (!$api->send()) {
    // We can examine the response... but they always return 200...
    $api->getResponse()->getStatusCode();
    
    // We can check for what response came up
    $response = $api->getResponse()->xml();
    
    switch ($response) {
        case 'Invalid Email.':
            // Do logic for Invalid Email according to their API
        break;
        case 'Invalid Source.':
            // Do logic for Invalid Source according to their API
        break;
    }
}

目前已知响应

  • 成功。
  • 无效电子邮件。
  • 无效源URL。
  • 无效IP地址。
  • 无效日期。

谢谢,

-Casey