1

Aweber サブスクライバー情報、特にカスタム フィールドを更新しようとしています。Aweber API を使用していますが、機能しておらず、コードを正しく記述していない可能性があります。

require_once('../AweberAPI/aweber_api/aweber_api.php');
include("../config.php");

$email=$_POST["email"];
$threefears=$_POST["3fears"];
$handlefears=$_POST["handlefears"];
$threeactions=$_POST["3actions"];
$changelife=$_POST["changelife"];

$consumerKey    = '';
$consumerSecret = '';
$accessKey      = '***'; # put your credentials here
$accessSecret   = '***'; # put your credentials here
$account_id     = ''; # put the Account ID here
$list_id        = ''; # put the List ID here

$aweber = new AWeberAPI($consumerKey, $consumerSecret);


try {
    $custom_field->name = 'Favorite Color';
    $custom_field->save();  



    $params = array('email' => '$email');
    $found_subscribers = $account->findSubscribers($params);
    foreach($found_subscribers as $subscriber) {
        $subscriber->custom_fields = array(
                'Top 3 biggest fears related to dating' => '$threefears',
                'How would the person you most admire handle these fears' => '$handlefears',
                'What are 3 actions you can take today to act more like the person you most admire' => '$threeactions',
                'How will taking these actions change your attitude towards dating and your life' => '$changelife',
            );
        $subscriber->save();
    }
}
4

3 に答える 3

1

送信するカスタム フィールドは、API 経由で送信する前にリストに存在している必要があります。これは、次のプロセスを使用して aweber コントロール パネル内で行うことができます: https://help.aweber.com/hc/en-us/articles/204027516-How-Do-I-Create-Custom-Fields-

したがって、'age' という名前のカスタム フィールドを作成した場合、コードは次のようになります (既存の $subscriber オブジェクトを想定)。

$fields = array(
    'age' => '21',
);
$subscriber->custom_fields = $fields;
$subscriber->save();

また

$subscriber['custom_fields']['age'] = '21';
$subscriber->save();
于 2016-06-20T20:14:30.913 に答える
0

値を書く代わりに、$threefears、$handlefears などをテキストとして書いていると思います。

あなたの例では、変数を $variable ではなく '$variable' として配置しています。これは、変数の内容ではなく変数名を書き込みます。

そのため、代わりに

 $subscriber->custom_fields = array(
            'Top 3 biggest fears related to dating' => '$threefears',
            'How would the person you most admire handle these fears' => '$handlefears',
            'What are 3 actions you can take today to act more like the person you most admire' => '$threeactions',
            'How will taking these actions change your attitude towards dating and your life' => '$changelife',
        );

試す

$subscriber->custom_fields = array(
                'Top 3 biggest fears related to dating' => $threefears,
                'How would the person you most admire handle these fears' => $handlefears,
                'What are 3 actions you can take today to act more like the person you most admire' => $threeactions,
                'How will taking these actions change your attitude towards dating and your life' => $changelife
            );

stackoverflow でさえ、変数名を正しく強調表示するようになったことに注意してください。ピートのために、カスタム フィールドの名前を短くしてください :) 確かに、作成できる投稿には制限があります。このような長い変数名を使用すると、投稿ごとに変数値のスペースが少なくなります。

あ、削除します

$custom_field->name = 'Favorite Color';
$custom_field->save();  

そしてから変更します

$params = array('email' => '$email');

$params = array('email' => $email);

または

$params = array('email' => $email, 'status' => 'subscribed');
于 2015-12-08T22:07:07.090 に答える