2014-12-19 33 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

相关问题