2014-12-19 32 views
0

我試圖將離線轉換上傳到Google Adwords,但我在$uploadResult = $conversionService->mutate($operations)調用中遇到錯誤。我得到的錯誤是RequiredError.REQUIRED @ operations[0].operand.conversionGclid,對於陣列中的每個操作都有相同的條目。當gclid存在時需要gclid錯誤

根據該文件,當需要的字段保留爲空,則拋出這個錯誤,但我知道該字段不爲空,因爲下面一行返回值:

foreach($opperations as $opp){ 
     print "Value of opp->gclid : " . $opp->operand->googleClickID . "\n\n"; 
    } 

我使用收集到的信息查詢,這是我的代碼來處理結果:

if($queryResult->rowCount() > 0){ 
    print "Query returned " . $queryResult->rowCount() . " rows\n\n"; 

    $operations = array(); 
    while($row = $queryResult->fetch(PDO::FETCH_ASSOC)){ 

     $feed = new OfflineConversionFeed(); 
     $feed->conversionName = $conversionName; 
     $feed->conversionTime = $row['conversion_datetime']; 
     $feed->googleClickID = $row['gclid']; 

     $operations[] = new OfflineConversionFeedOperation($feed, 'ADD'); 
    } 

    foreach($opperations as $opp){ 
     print "Value of opp->gclid : " . $opp->operand->googleClickID . "\n\n"; 
    } 

    //Following line throws error------------ 
    $uploadResult = $conversionService->mutate($operations); 
    printf('Upload for %s : %s complete', $user->GetClientCustomerId() , $conversionName); 
    return; 
} 
printf('No records for %s found', $user->GetClientCustomerId()); 

回顧過去所發現的herehere,這應該沒有任何問題的工作樣本,但我得到了RequiredError

回答

0

我想你已經使用了錯誤的字段名稱。你在大寫中使用了ID。

try this

$進料=新OfflineConversionFeed();

$ feed-> googleClickId = $ row ['gclid'];

instead of:

$饋> googleClickID = $行[ 'GCLID'];

可能會修復問題。

+0

這樣做。我實際上是通過使用它的構造函數,''new OfflineConversionFeed($ row ['gclid'],$ conversionName,$ row ['conversion_datetime'])''來實現它的,但我只是用你的答案來嘗試它,也工作。 – JRLambert 2014-12-22 20:24:51

相關問題