hi peter 

I have the same issue  when I try in PHP SDK given error php 


<?php
/**
 * Copyright 2017 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace Google\AdsApi\Examples\AdWords\v201809\Remarketing;

require 'googleads-php-lib-master/vendor/autoload.php';

use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201809\cm\Operator;
use Google\AdsApi\AdWords\v201809\rm\AddressInfo;
use Google\AdsApi\AdWords\v201809\rm\AdwordsUserListService;
use Google\AdsApi\AdWords\v201809\rm\CrmBasedUserList;
use Google\AdsApi\AdWords\v201809\rm\CustomerMatchUploadKeyType;
use Google\AdsApi\AdWords\v201809\rm\Member;
use Google\AdsApi\AdWords\v201809\rm\MutateMembersOperand;
use Google\AdsApi\AdWords\v201809\rm\MutateMembersOperation;
use Google\AdsApi\AdWords\v201809\rm\UserListOperation;
use Google\AdsApi\Common\OAuth2TokenBuilder;
use Google\AdsApi\AdWords\v201809\rm\UserListMembershipStatus;
use Google\AdsApi\AdWords\v201809\rm\AccessReason;
use Google\AdsApi\AdWords\v201809\rm\AccountUserListStatus;
use Google\AdsApi\AdWords\v201809\rm\UserListType;
/**
 * This example adds a user list (a.k.a. audience) and uploads members to
 * populate the list.
 *
 * <p><em>Note:</em> It may take up to several hours for the list to be
 * populated with members.
 * Email addresses must be associated with a Google account.
 * For privacy purposes, the user list size will show as zero until the 
list has
 * at least 1,000 members. After that, the size will be rounded to the two 
most
 * significant digits.
 */
class AddCrmBasedUserList{

    private static $EMAILS = [
        'custom...@gmail.com','custom...@gmail.com','clie...@gmail.com '
    ];

    public static function runExample(AdWordsServices 
$adWordsServices,AdWordsSession $session,array $emails) {
        try{
            /*for($i=4;$i<=$n;$i++){
                $emails[]= str_replace("1",$i,"custom...@example.com");
            }*/
            $userListService = $adWordsServices->get($session, 
AdwordsUserListService::class);
            // Create a CRM based user list.
            $userList = new CrmBasedUserList();
            $userList->setName('test_for_customer_count' . uniqid());
            $userList->setDescription('A list of customers that originated 
from email addresses');
            $userList->setsizeRange("ONE_MILLION_TO_TWO_MILLION");
            $userList->setstatus(UserListMembershipStatus::OPEN);
            // CRM-based user lists can use a membershipLifeSpan of 10000 to
            // indicate unlimited; otherwise normal values apply.
            // Sets the membership life span to 30 days.
            $userList->setMembershipLifeSpan(365);
            
$userList->setUploadKeyType(CustomerMatchUploadKeyType::CONTACT_INFO);
            $userList->setaccessReason(AccessReason::SHARED);
            
$userList->setaccountUserListStatus(AccountUserListStatus::ACTIVE);
            $userList->setlistType(UserListType::CRM_BASED);
            
            // Create a user list operation and add it to the list.
            $operations = [];
            $operation = new UserListOperation();
            $operation->setOperand($userList);
            $operation->setOperator(Operator::ADD);
            $operations[] = $operation;

            // Create the user list on the server and print out some 
information.
            $userList = 
$userListService->mutate($operations)->getValue()[0];
            printf("User list with name '%s' and ID %d was 
added.\n",$userList->getName(),$userList->getId());
            // Create operation to add members to the user list based on 
email
            // addresses.

            $mutateMembersOperations = [];
            $mutateMembersOperation = new MutateMembersOperation();
            $operand = new MutateMembersOperand();
            $operand->setUserListId($userList->getId());
            $members = [];
            // Hash normalized email addresses based on SHA-256 hashing 
algorithm.
            /*foreach ($emails as $email) {
                $memberByEmail = new Member();
                
$memberByEmail->setHashedEmail(self::normalizeAndHash($email));
                $members[] = $memberByEmail;
            }*/

            $n=40;
            for($i=4;$i<=$n;$i++){
                $emails[]= str_replace("1",$i,"custom...@gmail.com");
               // $email= str_replace("1",$i,"custom...@example.com");
                $memberByEmail = new Member();
                
$memberByEmail->setHashedEmail(self::normalizeAndHash($email));
                $members[] = $memberByEmail;
            }

            $firstName = 'John';
            $lastName = 'Doe';
            $countryCode = 'US';
            $zipCode = '10011';

            $addressInfo = new AddressInfo();
            // First and last name must be normalized and hashed.
            
$addressInfo->setHashedFirstName(self::normalizeAndHash($firstName));
            
$addressInfo->setHashedLastName(self::normalizeAndHash($lastName));
            // Country code and zip code are sent in plain text.
            $addressInfo->setCountryCode($countryCode);
            $addressInfo->setZipCode($zipCode);

            $memberByAddress = new Member();
            $memberByAddress->setAddressInfo($addressInfo);
            $members[] = $memberByAddress;

            // Add members to the operand and add the operation to the list.
            $operand->setMembersList($members);
            $mutateMembersOperation->setOperand($operand);
            $mutateMembersOperation->setOperator(Operator::ADD);
            $mutateMembersOperations[] = $mutateMembersOperation;

            // Add members to the user list based on email addresses.
            $result = 
$userListService->mutateMembers($mutateMembersOperations);

            // Print out some information about the added user list.
            // Reminder: it may take several hours for the list to be 
populated with
            // members.
            foreach ($result->getUserLists() as $userList) {
                printf(
                    "%d email addresses were uploaded to user list with 
name '%s'"
                    . " and ID %d and are scheduled for review.\n",
                    count($emails),
                    $userList->getName(),
                    $userList->getId()
                );
            }
        }catch(\Exception $e){
            echo "<pre>";
            print_r($e);
        }
    }

    private static function normalizeAndHash($value){
        return hash('sha256', strtolower(trim($value)));
    }
    public static function main(){
        // Generate a refreshable OAuth2 credential for authentication.
         
         $oauth_2_credential =(new OAuth2TokenBuilder())
            ->withClientId("xxxxxxx")
            ->withClientSecret("xxxxxxxx")
            ->withRefreshToken("xxxxxxxx")
            ->build();

        // Construct an API session configured from a properties file and 
the
        // OAuth2 credentials above.

        $session = (new AdWordsSessionBuilder())
                ->withDeveloperToken("xxxxxxxxxx")
                ->withOAuth2Credential($oauth_2_credential)
                ->withClientCustomerId("xxxxxxx4")
                ->build();
        self::runExample(new AdWordsServices(), $session, self::$EMAILS);
    }
}
AddCrmBasedUserList::main();
?>

*Errror* 

Google\AdsApi\AdWords\v201809\cm\ApiException Object
(
    [errors:protected] => Array
        (
            [0] => Google\AdsApi\AdWords\v201809\rm\UserListError Object
                (
                    [reason:protected] => USER_LIST_SERVICE_ERROR
                    [fieldPath:protected] => operations[0].operand
                    [fieldPathElements:protected] => Array
                        (
                            [0] => 
Google\AdsApi\AdWords\v201809\cm\FieldPathElement Object
                                (
                                    [field:protected] => operations
                                    [index:protected] => 0
                                )

                            [1] => 
Google\AdsApi\AdWords\v201809\cm\FieldPathElement Object
                                (
                                    [field:protected] => operand
                                    [index:protected] => 
                                )

                        )

                    [trigger:protected] => 
                    [errorString:protected] => 
UserListError.ADVERTISER_NOT_WHITELISTED_FOR_USING_UPLOADED_DATA
                    [ApiErrorType:protected] => UserListError
                    
[parameterMap:Google\AdsApi\AdWords\v201809\cm\ApiError:private] => Array
                        (
                            [ApiError.Type] => ApiErrorType
                        )

                )

        )

    [message1:protected] => 
[UserListError.ADVERTISER_NOT_WHITELISTED_FOR_USING_UPLOADED_DATA @ 
operations[0].operand]
    [ApplicationExceptionType:protected] => 
    
[parameterMap:Google\AdsApi\AdWords\v201809\cm\ApplicationException:private] => 
Array
        (
            [ApplicationException.Type] => ApplicationExceptionType
        )

    [message:protected] => 
[UserListError.ADVERTISER_NOT_WHITELISTED_FOR_USING_UPLOADED_DATA @ 
operations[0].operand]
    [string:Exception:private] => 
    [code:protected] => 0
    [file:protected] => 
/var/www/html/google_audience_manager/googleads-php-lib-master/src/Google/AdsApi/Common/Util/Reflection.php
    [line:protected] => 43
    [trace:Exception:private] => Array
       

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/8cfe87a9-973c-4e8f-8f57-7e755122ce0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • ... alex
    • ... 'Peter Oliquino (AdWords API Team)' via AdWords API and Google Ads API Forum
      • ... simprosys2harshtest
    • ... Joana Esteves
    • ... alex
      • ... 'Thanet Knack Praneenararat (AdWords API Team)' via AdWords API and Google Ads API Forum
        • ... ant
          • ... 'Thanet Knack Praneenararat (AdWords API Team)' via AdWords API and Google Ads API Forum
        • ... alex
          • ... 'Thanet Knack Praneenararat (AdWords API Team)' via AdWords API and Google Ads API Forum
            • ... alex
              • ... 'Thanet Knack Praneenararat (AdWords API Team)' via AdWords API and Google Ads API Forum

Reply via email to