0
完全なコードを作成することを約束します。使用はがつがつ食うとmailchimpリストに
私は私が得たphp create_list_memeber_update.php
エラーを実行しています:
PHP Fatal error: Uncaught InvalidArgumentException: Invalid resource type: array in /var/www/html/test/testme/test_guzzle/vendor/guzzlehttp/psr7/src/functions.php:116
Stack trace:
#0 /var/www/html/test/testme/test_guzzle/vendor/guzzlehttp/psr7/src/Request.php(53): GuzzleHttp\Psr7\stream_for(Array)
#1 /var/www/html/test/testme/test_guzzle/create_list_memeber_update.php(49): GuzzleHttp\Psr7\Request->__construct('POST', Object(GuzzleHttp\Psr7\Uri), Array, Array)
#2 {main}
thrown in /var/www/html/test/testme/test_guzzle/vendor/guzzlehttp/psr7/src/functions.php on line 116
私は
$headers = array(
'User-Agent' => 'testing/1.0',
'Accept' => 'application/json'
);
コードcreate_list_memeber_update.phpのヘッダーに何かあると思う:
<?php
// auto load
require 'vendor/autoload.php';
use GuzzleHttp\Psr7\Request;
// opt
$option = array(
'base_uri' => "https://us12.api.mailchimp.com/3.0/",
'auth' => ['apikey', '292bae37c631ac3ba03ed0640b44e6c3'],
);
// client
$client = new \GuzzleHttp\Client($option);
// data for a new list
$data = array(
"name" => "test_mailchimp",
"contact" => array(
"company" => "MailChimp",
"address1" => "675 Ponce De Leon Ave NE",
"address2" => "Suite 5000",
"city" => "Atlanta",
"state" => "GA",
"zip" => "30308",
"country" => "US",
"phone" => "12345678",
),
"permission_reminder" => "You're receiving this email because you signed up for updates.",
"use_archive_bar" => true,
"campaign_defaults" => array(
"from_name" => "test",
"from_email" => "[email protected]",
"subject" => "test_subject",
"language" => "en",
),
"notify_on_subscribe" => "",
"notify_on_unsubscribe" => "",
"email_type_option" => true,
"visibility" => "pub",
);
$headers = array(
'User-Agent' => 'testing/1.0',
'Accept' => 'application/json'
);
$body = ['json' => $data];
$req_create_list = new Request('POST', 'lists', $headers, $body);
// promise
$promise = $client
->sendAsync($req_create_list)
->then(function ($res) {
echo $res->getBody();
});
$promise->wait();
完全に正常に動作し 'リソースまたはオブジェクトのいずれかを期待されているstream_for'。 – RobFos