Re: Download report without saving
Hi Anash, Thank you for your quick response! However, I can't make the code work. The $result variable remains empty, but when I check the $httpCode variable I can see that it has a value of 200 which indicates that nothing went wrong in the request. Below is a part of the code that I'm trying to run. public static function DownloadReport($clientId, $reportDefintionId, $path = NULL, AdWordsUser $user, $server = NULL) { $url = sprintf('%s/api/adwords/reportdownload?__rd=%s', isset($server) ? $server : $user->GetDefaultServer(), $reportDefintionId); // The authorization token and client identifier must be set as HTTP // headers. $headers = array(); $headers[]= 'Authorization: GoogleLogin auth=' . $user- >GetAuthToken(); $headers[] = 'clientCustomerId: ' . $clientId; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); if (defined('HTTP_PROXY_HOST') && HTTP_PROXY_HOST != '') { curl_setopt($ch, CURLOPT_PROXY, HTTP_PROXY_HOST); } if (defined('HTTP_PROXY_PORT') && HTTP_PROXY_PORT != '') { curl_setopt($ch, CURLOPT_PROXYPORT, HTTP_PROXY_PORT); } if (defined('HTTP_PROXY_USER') && defined('HTTP_PROXY_PASSWORD') && HTTP_PROXY_USER != '' && HTTP_PROXY_PASSWORD != '') { curl_setopt($ch, CURLOPT_PROXYUSERPWD, HTTP_PROXY_USER . ':' . HTTP_PROXY_PASSWORD); } $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); $downloadSize = curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD); curl_close($ch); if ($httpCode != 200) { throw new ReportDownloadException($error, $httpCode); } $matches = array(); if (preg_match(ReportUtils::$REPORT_ERROR_MESSAGE_REGEX, $result, $matches)) { echo new ReportDownloadException($matches[1]); } print "Result: ".$result.", ".$downloadSize.", ".$error.", ". $httpCode; } } On 24 Aug, 13:23, AdWords API Advisor wrote: > Hi Robert, > > The code to achieve this is quite similar > tohttp://code.google.com/p/google-api-adwords-php/source/browse/trunk/e > If you pass a null to $path, then ReportUtils::DownloadReport returns > you the actual report contents. > Seehttp://code.google.com/p/google-api-adwords-php/source/browse/trunk/s... > for more details. > > Cheers, > Anash P. Oommen, > AdWords API Advisor. > > On Aug 23, 12:31 am, "robert.johans...@adwire.se" > > > > wrote: > > Hi, > > > In the PHP client library I can find an example of how to download a > > report created by the new reportDefinitionService. But how can I get > > the report without saving it as a file, but instead open it in memory > > (like with the old reports)? There is no need for me to save it as a > > file, as I just want to save the data into my database. > > > Thank you in advance!- Dölj citerad text - > > - Visa citerad text - -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.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
Re: Download report without saving
Hi Anash, Thank you for your quick response! However, I can't make the code work. The $result variable remains empty, but when I check the $httpCode variable I can see that it has a value of 200 which indicates that nothing went wrong in the request. Below is a part of the code that I'm trying to run. public static function DownloadReport($clientId, $reportDefintionId, $path = NULL, AdWordsUser $user, $server = NULL) { $url = sprintf('%s/api/adwords/reportdownload?__rd=%s', isset($server) ? $server : $user->GetDefaultServer(), $reportDefintionId); // The authorization token and client identifier must be set as HTTP // headers. $headers = array(); $headers[]= 'Authorization: GoogleLogin auth=' . $user- >GetAuthToken(); $headers[] = 'clientCustomerId: ' . $clientId; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); if (defined('HTTP_PROXY_HOST') && HTTP_PROXY_HOST != '') { curl_setopt($ch, CURLOPT_PROXY, HTTP_PROXY_HOST); } if (defined('HTTP_PROXY_PORT') && HTTP_PROXY_PORT != '') { curl_setopt($ch, CURLOPT_PROXYPORT, HTTP_PROXY_PORT); } if (defined('HTTP_PROXY_USER') && defined('HTTP_PROXY_PASSWORD') && HTTP_PROXY_USER != '' && HTTP_PROXY_PASSWORD != '') { curl_setopt($ch, CURLOPT_PROXYUSERPWD, HTTP_PROXY_USER . ':' . HTTP_PROXY_PASSWORD); } $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); $downloadSize = curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD); curl_close($ch); if ($httpCode != 200) { throw new ReportDownloadException($error, $httpCode); } $matches = array(); if (preg_match(ReportUtils::$REPORT_ERROR_MESSAGE_REGEX, $result, $matches)) { echo new ReportDownloadException($matches[1]); } print "Result: ".$result.", ".$downloadSize.", ".$error.", ". $httpCode; } } On 24 Aug, 13:23, AdWords API Advisor wrote: > Hi Robert, > > The code to achieve this is quite similar > tohttp://code.google.com/p/google-api-adwords-php/source/browse/trunk/e > If you pass a null to $path, then ReportUtils::DownloadReport returns > you the actual report contents. > Seehttp://code.google.com/p/google-api-adwords-php/source/browse/trunk/s... > for more details. > > Cheers, > Anash P. Oommen, > AdWords API Advisor. > > On Aug 23, 12:31 am, "robert.johans...@adwire.se" > > > > wrote: > > Hi, > > > In the PHP client library I can find an example of how to download a > > report created by the new reportDefinitionService. But how can I get > > the report without saving it as a file, but instead open it in memory > > (like with the old reports)? There is no need for me to save it as a > > file, as I just want to save the data into my database. > > > Thank you in advance!- Dölj citerad text - > > - Visa citerad text - -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.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
View geoTargetList
Hi, I am using Adwords php lib for v201003. I need to get listing of all Campaign Target lists. In the examples section of php lib, I am using GetAllCampaignTargets.php. It only shows the types of Targets. code is: $user = new AdWordsUser(); $campaignTargetService = $user->GetCampaignTargetService('v201003'); $campaignId = (float) '1'; $selector = new CampaignTargetSelector(); $selector->campaignIds = array($campaignId); $page = $campaignTargetService->get($selector); if (isset($page->entries)) { print_r($page->entries) } Output is something like this: [1] => DemographicTargetList Object ( [targets] => [campaignId] => 130071 [TargetListType] => DemographicTargetList [_parameterMap:private] => Array ( [TargetList.Type] => TargetListType ) ) [2] => GeoTargetList Object ( [targets] => [campaignId] => 130071 [TargetListType] => GeoTargetList [_parameterMap:private] => Array ( [TargetList.Type] => TargetListType ) ) How can I get complete list of all geo targets? Thanks. -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.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