ianchadwick/maxcontact

MaxContact PHP API

dev-master 2016-07-22 12:48 UTC

This package is not auto-updated.

Last update: 2024-09-26 01:35:35 UTC


README

... 好吧,csv文件上传!

要求

PHP 5.4+

使用Composer安装

将ianchadwick/maxcontact添加到composer.json文件的要求部分

"require": {
  "ianchadwick/maxcontact": "dev-master"
}

然后使用composer更新项目

composer update

CSV文件上传到映射

use MaxContact\Client;
use MaxContact\Commands\ImportCsvFiles;

# Create a new client, the url is unique to each account so you'll want to speak to MaxContact support to get yours.
# They will also be able to provide you with the username and password for use with the API.
$client = new Client('username', 'password', 'https://myusernameapi.maxcontact.com/myusernameapi');

# Create some kind of file upload
# List ID and mapping name will be provided by support again.
# The mapping that is requested will determine the key names below.
$command = new ImportJsonFiles(1, 'LiveFeedMap', [
    [
        'firstName' => 'Ian',
        'phone' => '012345678765',
        # ... any additional feeds that are mapped
    ]
]);

# upload the file and return a true on success
$client->execute($command);

# To get the response from the last request
var_dump($client->getLastResponse()->getBody()->getContents());

# Or get the XML
var_dump($client->getLastResponse()->xml());