用于拉列表的MailChimp PHP脚本
我正试图编写一个.JSON来从我的MailChimp帐户中提取订户列表。我遵循了网站上的文档,并拥有以下信息:用于拉列表的MailChimp PHP脚本,php,json,mailchimp,Php,Json,Mailchimp,我正试图编写一个.JSON来从我的MailChimp帐户中提取订户列表。我遵循了网站上的文档,并拥有以下信息: { "name": "export/export", "description": "MailChimp Export", "require": { "mailchimp/mailchimp": "dev- master", "apigen/apigen": "~4.1@dev" }, "authors": [
{
"name": "export/export",
"description": "MailChimp Export",
"require": {
"mailchimp/mailchimp": "dev-
master",
"apigen/apigen": "~4.1@dev"
},
"authors": [
{
"name": "Ben Loya",
"email": "bal2155@columbia.edu"
}
],
"minimum-stability": "dev"
}
$apikey = '6e1f2f874b81bbbd8a8d1dcae88353c1-us7';
$list_id = 'CUFSN Members';
$chunk_size = 4096; //in bytes
$url = 'http://us7.api.mailchimp.com/export/1.0/list?apikey='.$apikey.'&id='.$list_id;
/** a more robust client can be built using fsockopen **/
$handle = @fopen($url,'r');
if (!$handle) {
echo "failed to access url\n";
} else {
$i = 0;
$header = array();
while (!feof($handle)) {
$buffer = fgets($handle, $chunk_size);
if (trim($buffer)!=''){
$obj = json_decode($buffer);
if ($i==0){
//store the header row
$header = $obj;
} else {
//echo, write to a file, queue a job, etc.
echo $header[0].': '.$obj[0]."\n";
}
$i++;
}
}
fclose($handle);
}
当我运行composer install
时,我得到以下信息:
[Seld\JsonLint\ParsingException]
"./composer.json" does not contain valid JSON
Parse error on line 15:
$apikey = '6e1f2f874
------------------^
Expected one of: 'EOF', '}', ',', ']'
我的语法有什么问题?我对.JSON格式非常陌生-请原谅任何愚蠢和/或明显的错误 我建议您使用检查语法
“mailchimp/mailchimp”后面有空格:“dev-”,不应该在那里
为了避免这些json输入错误,您可以通过CLI使用如下安装包:
composer require-mailchimp/mailchimp