Hi Adwords Team, i dont understand what the meaning this error and why i 
have this error :

[message:protected] => [AdError.INVALID_AD_TYPE @ operations[0].operand.ad]

Can you help me please to solve this problem?

here are my script and response soap; thank you in advance.

My script : 
*******************************************************************************
******************************Begin 
script***********************************
*******************************************************************************
require_once 'src/Google/Api/Ads/AdWords/v201306/AdGroupAdService.php';




define("ADWORDS_API_VERSION", "v201306");
 
// Production API
//define("ADWORDS_API_SERVER", "https://adwords.google.com";);
// Sandbox API
define("ADWORDS_API_SERVER", "https://adwords.google.com";);
 
define("ADWORDS_API_NAMESPACE", "https://adwords.google.com/api/adwords/cm/"; 
. ADWORDS_API_VERSION);
define("ADWORDS_API_ADGROUPADSERVICE", ADWORDS_API_SERVER . 
"/api/adwords/cm/" . ADWORDS_API_VERSION . "/AdGroupAdService");
 
// Your API Developer Token
define("ADWORDS_API_TOKEN", "******************************");
 
// The account that you want to download performace data from
$username = "t...@gmail.com";
$password = "************))";
$customerId = "576-***-3559";
 
try {
    // Get an auth token for the user
    $url = "https://www.google.com/accounts/ClientLogin";;
    $params = array(
        "accountType" => "GOOGLE",
        "Email" => $username,
        "Passwd" => $password,
        "service" => "adwords",
        "source" => "test"
    );
 
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
    curl_setopt($curl, CURLOPT_ENCODING, "");
    $curlData = curl_exec($curl);
    curl_close($curl);
 
    $pos = strpos($curlData, "Auth=");
    if ($pos > -1) {
        $auth = trim(substr($curlData, $pos + 5));
    } else {
        throw new Exception("You haven't supplied a valid username or 
password for an existing Google account.");
    }
    // Create the headers needed to access the API
    $headers = array(
        "developerToken" => ADWORDS_API_TOKEN,
        "userAgent" => "agence",
        "clientCustomerId" => $customerId,
        "authToken" => $auth
    );
 
    // Encode the headers
    $encodedHeaders = new SoapHeader(ADWORDS_API_NAMESPACE, 
"RequestHeader", $headers, false);
 
$options = array(
    'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
    'encoding' => 'utf-8');
   
    // Create the SOAP client
    
    $client = new SoapClient(ADWORDS_API_ADGROUPADSERVICE . "?wsdl", 
$options);
   
    $client->__setSoapHeaders($encodedHeaders);

$adGroupId = '8424820921';


$numAds = 5;
  $operations = array();
 // for ($i = 0; $i < $numAds; $i++) {
    // Create text ad.
      $textAd = new TextAd();
    $textAd->headline = 'Cruise';
    $textAd->description1 = 'Visit';
    $textAd->description2 = 'Low-gravity';
    $textAd->displayUrl = 'www.example.com';
    $textAd->url = 'http://www.example.com';
     $textAd->AdType = "TextAd";
    
     
     
    // Create ad group ad.
    $adGroupAd = new AdGroupAd();
    $adGroupAd->adGroupId = $adGroupId;
    $adGroupAd->ad = $textAd;

    // Set additional settings (optional).
    $adGroupAd->status = 'PAUSED';

    // Create operation.
    $operation = new AdGroupAdOperation();
    $operation->operand = $adGroupAd;
    $operation->operator = 'ADD';
    $operations[] = $operation;
 // }

  // Make the mutate request.
  $result = $client->mutate($operations);

  // Display results.
  foreach ($result->value as $adGroupAd) {
    printf("Text ad with headline '%s' and ID '%s' was added.\n",
        $adGroupAd->ad->headline, $adGroupAd->ad->id);
  }



       
} catch (Exception $e) {
    print_r($e);
    if (isset($client)) {
        print $client->__getLastRequest() . "\n";
        print $client->__getLastResponse() . "\n";
    }
} 
**********************************END SCRIPT*******************************

*********************************************************************************
*********************************************************************************
*******************************RESPONSE SOAP********************
SoapFault Object
(
    [message:protected] => [AdError.INVALID_AD_TYPE @ operations[0].
operand.ad]
    [string:Exception:private] => 
    [code:protected] => 0
    [file:protected] => /var/www/vhosts/httpdocs/
example.com/adwords_api_php_4.6.1/autreesai.php
    [line:protected] => 122
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [file] => /var/www/vhosts/httpdocs/
example.com/adwords_api_php_4.6.1/autreesai.php
                    [line] => 122
                    [function] => __call
                    [class] => SoapClient
                    [type] => ->
                    [args] => Array
                        (
                            [0] => mutate
                            [1] => Array
                                (
                                    [0] => Array
                                        (
                                            [0] => AdGroupAdOperation Object
                                                (
                                                    [operand] => AdGroupAd 
Object
                                                        (
                                                            [adGroupId] => 
8424820921
                                                            [ad] => TextAd 
Object
                                                                (
                                                                    
[headline] => Cruise
                                                                    
[description1] => Visit
                                                                    
[description2] => Low-gravity
                                                                    [id] => 
                                                                    [url] =>
 http://www.example.com
                                                                    
[displayUrl] => www.example.com
                                                                    
[devicePreference] => 
                                                                    
[disapprovalReasons] => 
                                                                    
[AdType] => TextAd
                                                                    
[_parameterMap:Ad:private] => Array
                                                                        (
                                                                            
[Ad.Type] => AdType
                                                                        )

                                                                )

                                                            
[experimentData] => 
                                                            [status] => 
PAUSED
                                                            
[approvalStatus] => 
                                                            
[trademarkDisapproved] => 
                                                            [stats] => 
                                                            
[forwardCompatibilityMap] => 
                                                        )

                                                    [exemptionRequests] => 
                                                    [operator] => ADD
                                                    [OperationType] => 
                                                    
[_parameterMap:Operation:private] => Array
                                                        (
                                                            
[Operation.Type] => OperationType
                                                        )

                                                )

                                        )

                                )

                        )

                )

            [1] => Array
                (
                    [file] => /var/www/vhosts/
example.com/adwords_api_php_4.6.1/autreesai.php
                    [line] => 122
                    [function] => mutate
                    [class] => SoapClient
                    [type] => ->
                    [args] => Array
                        (
                            [0] => Array
                                (
                                    [0] => AdGroupAdOperation Object
                                        (
                                            [operand] => AdGroupAd Object
                                                (
                                                    [adGroupId] => 
8424820921
                                                    [ad] => TextAd Object
                                                        (
                                                            [headline] => 
Cruise
                                                            [description1] 
=> Visit
                                                            [description2] 
=> Low-gravity
                                                            [id] => 
                                                            [url] => 
http://www.example.com
                                                            [displayUrl] => 
www.example.com
                                                            
[devicePreference] => 
                                                            
[disapprovalReasons] => 
                                                            [AdType] => 
TextAd
                                                            
[_parameterMap:Ad:private] => Array
                                                                (
                                                                    
[Ad.Type] => AdType
                                                                )

                                                        )

                                                    [experimentData] => 
                                                    [status] => PAUSED
                                                    [approvalStatus] => 
                                                    [trademarkDisapproved] 
=> 
                                                    [stats] => 
                                                    
[forwardCompatibilityMap] => 
                                                )

                                            [exemptionRequests] => 
                                            [operator] => ADD
                                            [OperationType] => 
                                            
[_parameterMap:Operation:private] => Array
                                                (
                                                    [Operation.Type] => 
OperationType
                                                )

                                        )

                                )

                        )

                )

        )

    [previous:Exception:private] => 
    [faultstring] => [AdError.INVALID_AD_TYPE @ operations[0].operand.ad]
    [faultcode] => soap:Server
    [detail] => stdClass Object
        (
            [ApiExceptionFault] => stdClass Object
                (
                    [message] => [AdError.INVALID_AD_TYPE @ operations[0].
operand.ad]
                    [ApplicationException.Type] => ApiException
                    [errors] => SoapVar Object
                        (
                            [enc_type] => 0
                            [enc_value] => stdClass Object
                                (
                                    [fieldPath] => operations[0].operand.ad
                                    [trigger] => 
                                    [errorString] => AdError.INVALID_AD_TYPE
                                    [ApiError.Type] => AdError
                                    [reason] => INVALID_AD_TYPE
                                )

                            [enc_stype] => AdError
                            [enc_ns] => 
https://adwords.google.com/api/adwords/cm/v201306
                        )

                )

        )

)
**********************************************************************************************
***********************************************************************************************


-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to