Re: migration ADGROUP_PERFORMANCE_REPORT

2021-10-21 Thread Василий Рогачев

I call this report, as before, through curl. This should work, right? This 
is exactly how the old report works for me.
четверг, 21 октября 2021 г. в 20:59:22 UTC+3, Василий Рогачев: 

>
> https://googleads.googleapis.com/v8/customers/CUSTOMER_ID/googleAds
>
>
> __fmt=TSV&__rdquery=SELECT segments.date, campaign.id, campaign.name, 
> ad_group.id, ad_group.name, metrics.impressions, metrics.clicks, 
> metrics.cost_micros FROM ad_group WHERE ad_group.status IN 
> ("ENABLED","PAUSED") AND segments.date DURING LAST_7_DAYS
>
>
> Everything works in the old way, but nothing is given in the new way. 
> Although only the query and url have been replaced
>
> четверг, 21 октября 2021 г. в 13:55:26 UTC+3, adsapi: 
>
>> Hi,
>>
>> This is Yasar and I work with Matt. Let me assist you with this.
>>
>> You may use the *ad_group* 
>> <https://developers.google.com/google-ads/api/fields/v8/ad_group?hl=en> 
>> report in Google Ads API which is equivalent to ADGROUP_PERFORMANCE_REPORT 
>> in the AdWords API. The Google Ads API can be called either using *gRPC* 
>> <https://grpc.io/> or REST, and we recommend using Google's official *client 
>> libraries* 
>> <https://developers.google.com/google-ads/api/docs/client-libs>.
>>
>> That said, you may create queries using either of the Search or 
>> SearchStream methods to get an ad_group report. Note that both Search and 
>> SearchStream use the same base URL below.
>>
>> https://googleads.googleapis.com/v8/customers/CUSTOMER_ID/googleAds
>>
>> For more information, you may refer to *this* 
>> <https://developers.google.com/google-ads/api/rest/common/search?hl=en> 
>> guide.
>>
>> Let us know if you have any further questions.
>>
>> Regards, 
>> [image: Google Logo] 
>> Yasar 
>> Google Ads API Team 
>>   
>>
>> ref:_00D1U1174p._5004Q2PL1eJ:ref
>>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/7f00fefd-fca6-40c6-9b6a-312ca045f79an%40googlegroups.com.


Re: migration ADGROUP_PERFORMANCE_REPORT

2021-10-21 Thread Василий Рогачев

https://googleads.googleapis.com/v8/customers/CUSTOMER_ID/googleAds


__fmt=TSV&__rdquery=SELECT segments.date, campaign.id, campaign.name, 
ad_group.id, ad_group.name, metrics.impressions, metrics.clicks, 
metrics.cost_micros FROM ad_group WHERE ad_group.status IN 
("ENABLED","PAUSED") AND segments.date DURING LAST_7_DAYS


Everything works in the old way, but nothing is given in the new way. 
Although only the query and url have been replaced

четверг, 21 октября 2021 г. в 13:55:26 UTC+3, adsapi: 

> Hi,
>
> This is Yasar and I work with Matt. Let me assist you with this.
>
> You may use the *ad_group* 
>  
> report in Google Ads API which is equivalent to ADGROUP_PERFORMANCE_REPORT 
> in the AdWords API. The Google Ads API can be called either using *gRPC* 
>  or REST, and we recommend using Google's official *client 
> libraries* 
> .
>
> That said, you may create queries using either of the Search or 
> SearchStream methods to get an ad_group report. Note that both Search and 
> SearchStream use the same base URL below.
>
> https://googleads.googleapis.com/v8/customers/CUSTOMER_ID/googleAds
>
> For more information, you may refer to *this* 
>  
> guide.
>
> Let us know if you have any further questions.
>
> Regards, 
> [image: Google Logo] 
> Yasar 
> Google Ads API Team 
>   
>
> ref:_00D1U1174p._5004Q2PL1eJ:ref
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/bfa54e60-c1b8-48a1-abef-e8f0f303e51dn%40googlegroups.com.


Re: migration ADGROUP_PERFORMANCE_REPORT

2021-10-20 Thread Василий Рогачев
And what url should be called? Previously it was 
https://adwords.google.com/api/adwords/reportdownload/v201809

среда, 20 октября 2021 г. в 17:33:01 UTC+3, adsapi: 

> Hello,
>
> Thanks for reaching out. You can use the Query Migration Tool 
> 
>  
> to convert AdWords API queries to the Ads API. For your query, the tool 
> provides the Ads API equivalent below:
>   
> SELECT segments.date, campaign.id, campaign.name, ad_group.id, 
> ad_group.name, metrics.impressions, metrics.clicks, metrics.cost_micros 
> FROM ad_group WHERE ad_group.status IN ("ENABLED","PAUSED") AND 
> segments.date DURING LAST_7_DAYS
>
> Regards,
> Matt
> Google Ads API Team
>
> [image: Google Logo] 
> Matt 
> Google Ads API Team 
>   
>
> ref:_00D1U1174p._5004Q2PL1eJ:ref
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/29946d5a-113d-45b7-9dde-fbc398470d4en%40googlegroups.com.


migration ADGROUP_PERFORMANCE_REPORT

2021-10-19 Thread Василий Рогачев
Good evening!

How to go from a request

SELECT Date, CampaignId, CampaignName, AdGroupId, AdGroupName, Impressions, 
Clicks, Cost

 FROM ADGROUP_PERFORMANCE_REPORT

 WHERE AdGroupStatus IN [ENABLED, PAUSED] DURING LAST_7_DAYS

to the new version of the Google Ads API?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/8e1ab262-0204-406c-b10f-d8dcbc63d7f8n%40googlegroups.com.


extension for ads

2020-12-19 Thread Василий Рогачев
Hello!

How do I get the url from ad extensions? In AD_PERFORMANCE_REPORT you can 
get?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/d76315ef-ad50-4647-8b68-ee293f30d8f3n%40googlegroups.com.


DEVELOPER_TOKEN_PARAMETER_MISSING

2020-02-24 Thread Василий Рогачев
Hello!


[primary_port] => 443
[local_ip] => 87.236.01.01
[local_port] => 27441
[request_header] => POST /v2/customers/11/googleAds:search HTTP/1.1 
Host: googleads.googleapis.com 
User-Agent: curl, gzip 
Accept: / 
Authorization: Bearer ya29.a..
developerToken: N
Expect: 100-continue 
Content-Length:212 
Connection: Keep-Alive 
Content-Type: application/json


request {"query":"SELECT campaign.name, campaign.status, segments.device, 
metrics.impressions, metrics.clicks, metrics.ctr, metrics.average_cpc, 
metrics.cost_micros FROM campaign WHERE segments.date DURING LAST_30_DAYS"}

"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": 
"type.googleapis.com/google.ads.googleads.v2.errors.GoogleAdsFailure",
"errors": [
{
"errorCode": {
"requestError": "DEVELOPER_TOKEN_PARAMETER_MISSING"
},
"message": "developer-token parameter is missing."
}
]
}
]
}
}

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/35336597-624c-47d6-874d-062dcfe3b9f3%40googlegroups.com.


Re: Get Balance Api Adwords

2020-02-21 Thread Василий Рогачев
 the Cost value from the Account Performance Report - How to get it?

On Friday, February 21, 2020 at 10:47:01 PM UTC+3, adsapiforumadvisor wrote:
>
> Hi,
>
> Thanks for reaching out. The way mentioned to calculate the balance is by 
> subtracting the spending from the pre-set budget on the account. The 
> Account Performance Report is the report for retrieving metrics for a 
> specific account within a date range. Once you get the Cost value from the 
> Account Performance Report, you could subtract it from the budget you set 
> for the account for the same period of time to know how much budget left 
> for the account.  
>
> Thanks and regards,
> Xiaoming, Google Ads API Team
>
>
>  
>
> ref:_00D1U1174p._5001UV1n7T:ref
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/a99447f2-19af-457f-8df5-68ba5d37e7fd%40googlegroups.com.


Get Balance Api Adwords

2020-02-21 Thread Василий Рогачев
Hello.

"Balance information is still not directly available via the AdWords API. 
Please continue to follow our blog 
 for 
updates.

However, as a workaround, you can compute the remaining balance by 
subtracting the total Cost 

 of 
the Account Performance Report 

 from 
your known budget."

Could you tell us more about calculating the balance? About calculating the 
cost of clicks, for a week it is clear "SELECT AccountDescriptiveName, 
Cost, AccountCurrencyCode   FROM ACCOUNT_PERFORMANCE_REPORT DURING 
LAST_7_DAYS". What is the Account Performance Report ? How is it 
calculated? And how is it related to the balance?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/da638b7d-fe35-42c2-859f-cf376154e3e7%40googlegroups.com.


Re: Post request for a report

2019-12-11 Thread Василий Рогачев
really looking forward to your response!

On Wednesday, December 11, 2019 at 1:02:30 AM UTC+3, adsapiforumadvisor 
wrote:
>
> Hello,
>
> Thanks you for reaching the support. The error "The server encountered a 
> temporary error and could not complete your request" could be a transient 
> error. Could you please retry the API request to verify if the issue 
> persists? If the issue is consistent, could you please share the complete 
> request and response logs along with the client customer id for me to 
> investigate this further on my end?
>
> P.S: Please use *Reply privately to author* option while sharing the 
> details.
>
> Regards,
> Nikisha Patel, Google Ads API Team
>
>
> ref:_00D1U1174p._5001UOEFAB:ref
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/6c62f70d-45e1-49e2-a417-c47542974ed9%40googlegroups.com.


Re: Post request for a report

2019-12-11 Thread Василий Рогачев
Your message to *adsapiforumadvi...@gmail.com* has been blocked. See 
technical details below for more information.

How then to send a message?

вторник, 10 декабря 2019 г., 20:52:18 UTC+3 пользователь Василий Рогачев 
написал:
>
>
> Good afternoon!
>
> First time working with the Adwords API. Before that, I worked with 
> Google's Contats API and there were no problems. And here I do not quite 
> understand why the request is not fulfilled?
>
> The program code in php below. An example of a query took 
> https://developers.google.com/adwords/api/docs/guides/reporting . But I 
> do not quite understand why there is no refresh token in the request ?
>
> *502.* That’s an error.
>
> The server encountered a temporary error and could not complete your 
> request.
>
>  $params1='{
>"reportDefinition": {
>"selector": {
>"fields": [
>"Campaign",
>"AdGroupId",
>"Impressions",
>"Clicks",
>"Cost"
>],
> "predicates": {
>"field": "AdGroupStatus",
>"operator": "IN",
>"values": [
>"ENABLED",
>"PAUSED"
>]
> }
>  },
>  "reportName": "Custom Adgroup Performance Report",
>  "reportType": "ADGROUP_PERFORMANCE_REPORT",
>  "dateRangeType": "LAST_7_DAYS",
>  "downloadFormat": "CSV",
>  "_xmlns": "https://adwords.google.com/api/adwords/cm/v201809;
>   }
> }';
> // Converts the input parameters of the query in JSON format
> $body = $params1;
>
> //print_r($body);
> //echo "___";
>
>
> // Creating HTTP request headers
>
>
>
> $headers = array(
>"Host: adwords.google.com",
>"User-Agent: curl, gzip",
>"Accept: /",
>"Accept-Encoding: gzip",
>"Authorization: Bearer ya29..g",
>"developerToken:NBQ",
>"clientCustomerId:124...li.apps.googleusercontent.com",
>"Content-Length: 784",
>"Expect: 100-continue",
>"Content-Type: multipart/form-data; 
> boundary=12d01fae60c7b559",
> );
>
>
>
>
>
>
>
> echo " < br>Adwords Report";
>
> // Curl initialization
> $curl = curl_init();
> curl_setopt($curl, CURLOPT_URL, $url);
> curl_setopt($curl, CURLOPT_POST, true);
> curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
>
> /*
> To fully use the https Protocol, you can enable SSL certificate 
> verification of the direct API server.
> To enable validation, set the CURLOPT_SSL_VERIFYPEER option to true, and 
> uncomment the string with the CURLOPT_CAINFO option and specify the path to 
> the local copy of the root SSL certificate.
> */
> curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
> // curl_setopt($curl, CURLOPT_CAINFO, getcwd().'\CA.pem');
>
> curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($curl, CURLOPT_HEADER, true);
> curl_setopt($curl, CURLINFO_HEADER_OUT, true);
> curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
>
> // - - - Run a loop to execute queries ---
> // If HTTP code 200 is received, the report content is displayed
> // If HTTP code 201 or 202 is received, repeated requests are made
> while (true) {
>
> $result = curl_exec($curl);
>
> if (!$result) {
>
> echo ('curl error:'.curl_errno($curl).'- ' .curl_error($curl));
>
> break;
>
> } else {
>
> // Separation of HTTP headers and the response body
>$responseHeadersSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
>$responseHeaders = substr($result, 0, $responseHeadersSize);
>$responseBody = substr($result, $responseHeadersSize);
>
> // Get HTTP status code
>$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
>
> // Retrieving HTTP response headers
>// Request ID
>$requestId = preg_match('/RequestId: (\d+)/', $responseHeaders, 
> $arr)? $arr[1]: false;
>// Recommended interval in seconds to check if the report is ready
>$retryIn = preg_match('/retryIn: (\d+)/', $responseHeaders, $arr)? 
> $arr[1]: 60;
>
> if ($httpCode == 400) {
>
> echo " the query Parameters are incorrect

Re: Post request for a report

2019-12-10 Thread 'Василий Рогачев' via AdWords API and Google Ads API Forum


$url = 'https://adwords.google.com/api/adwords/cm/v201809'; at the top in the 
code



вторник, 10 декабря 2019 г., 20:52:18 UTC+3 пользователь Василий Рогачев 
написал:
>
>
> Good afternoon!
>
> First time working with the Adwords API. Before that, I worked with 
> Google's Contats API and there were no problems. And here I do not quite 
> understand why the request is not fulfilled?
>
> The program code in php below. An example of a query took 
> https://developers.google.com/adwords/api/docs/guides/reporting . But I 
> do not quite understand why there is no refresh token in the request ?
>
> *502.* That’s an error.
>
> The server encountered a temporary error and could not complete your 
> request.
>
>  $params1='{
>"reportDefinition": {
>"selector": {
>"fields": [
>"Campaign",
>"AdGroupId",
>"Impressions",
>"Clicks",
>"Cost"
>],
> "predicates": {
>"field": "AdGroupStatus",
>"operator": "IN",
>"values": [
>"ENABLED",
>"PAUSED"
>]
> }
>  },
>  "reportName": "Custom Adgroup Performance Report",
>  "reportType": "ADGROUP_PERFORMANCE_REPORT",
>  "dateRangeType": "LAST_7_DAYS",
>  "downloadFormat": "CSV",
>  "_xmlns": "https://adwords.google.com/api/adwords/cm/v201809;
>   }
> }';
> // Converts the input parameters of the query in JSON format
> $body = $params1;
>
> //print_r($body);
> //echo "___";
>
>
> // Creating HTTP request headers
>
>
>
> $headers = array(
>"Host: adwords.google.com",
>"User-Agent: curl, gzip",
>"Accept: /",
>"Accept-Encoding: gzip",
>"Authorization: Bearer ya29..g",
>"developerToken:NBQ",
>"clientCustomerId:124...li.apps.googleusercontent.com",
>"Content-Length: 784",
>"Expect: 100-continue",
>"Content-Type: multipart/form-data; 
> boundary=12d01fae60c7b559",
> );
>
>
>
>
>
>
>
> echo " < br>Adwords Report";
>
> // Curl initialization
> $curl = curl_init();
> curl_setopt($curl, CURLOPT_URL, $url);
> curl_setopt($curl, CURLOPT_POST, true);
> curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
>
> /*
> To fully use the https Protocol, you can enable SSL certificate 
> verification of the direct API server.
> To enable validation, set the CURLOPT_SSL_VERIFYPEER option to true, and 
> uncomment the string with the CURLOPT_CAINFO option and specify the path to 
> the local copy of the root SSL certificate.
> */
> curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
> // curl_setopt($curl, CURLOPT_CAINFO, getcwd().'\CA.pem');
>
> curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($curl, CURLOPT_HEADER, true);
> curl_setopt($curl, CURLINFO_HEADER_OUT, true);
> curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
>
> // - - - Run a loop to execute queries ---
> // If HTTP code 200 is received, the report content is displayed
> // If HTTP code 201 or 202 is received, repeated requests are made
> while (true) {
>
> $result = curl_exec($curl);
>
> if (!$result) {
>
> echo ('curl error:'.curl_errno($curl).'- ' .curl_error($curl));
>
> break;
>
> } else {
>
> // Separation of HTTP headers and the response body
>$responseHeadersSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
>$responseHeaders = substr($result, 0, $responseHeadersSize);
>$responseBody = substr($result, $responseHeadersSize);
>
> // Get HTTP status code
>$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
>
> // Retrieving HTTP response headers
>// Request ID
>$requestId = preg_match('/RequestId: (\d+)/', $responseHeaders, 
> $arr)? $arr[1]: false;
>// Recommended interval in seconds to check if the report is ready
>$retryIn = preg_match('/retryIn: (\d+)/', $responseHeaders, $arr)? 
> $arr[1]: 60;
>
> if ($httpCode == 400) {
>
> echo " the query Parameters are incorrect or the limit of 
> reports in the queue has been

Post request for a report

2019-12-10 Thread 'Василий Рогачев' via AdWords API and Google Ads API Forum

Good afternoon!

First time working with the Adwords API. Before that, I worked with 
Google's Contats API and there were no problems. And here I do not quite 
understand why the request is not fulfilled?

The program code in php below. An example of a query took 
https://developers.google.com/adwords/api/docs/guides/reporting . But I do 
not quite understand why there is no refresh token in the request ?

*502.* That’s an error.

The server encountered a temporary error and could not complete your 
request.

https://adwords.google.com/api/adwords/cm/v201809;
  }
}';
// Converts the input parameters of the query in JSON format
$body = $params1;

//print_r($body);
//echo "___";


// Creating HTTP request headers



$headers = array(
   "Host: adwords.google.com",
   "User-Agent: curl, gzip",
   "Accept: /",
   "Accept-Encoding: gzip",
   "Authorization: Bearer ya29..g",
   "developerToken:NBQ",
   "clientCustomerId:124...li.apps.googleusercontent.com",
   "Content-Length: 784",
   "Expect: 100-continue",
   "Content-Type: multipart/form-data; 
boundary=12d01fae60c7b559",
);







echo " < br>Adwords Report";

// Curl initialization
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $body);

/*
To fully use the https Protocol, you can enable SSL certificate 
verification of the direct API server.
To enable validation, set the CURLOPT_SSL_VERIFYPEER option to true, and 
uncomment the string with the CURLOPT_CAINFO option and specify the path to 
the local copy of the root SSL certificate.
*/
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
// curl_setopt($curl, CURLOPT_CAINFO, getcwd().'\CA.pem');

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

// - - - Run a loop to execute queries ---
// If HTTP code 200 is received, the report content is displayed
// If HTTP code 201 or 202 is received, repeated requests are made
while (true) {

$result = curl_exec($curl);

if (!$result) {

echo ('curl error:'.curl_errno($curl).'- ' .curl_error($curl));

break;

} else {

// Separation of HTTP headers and the response body
   $responseHeadersSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
   $responseHeaders = substr($result, 0, $responseHeadersSize);
   $responseBody = substr($result, $responseHeadersSize);

// Get HTTP status code
   $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

// Retrieving HTTP response headers
   // Request ID
   $requestId = preg_match('/RequestId: (\d+)/', $responseHeaders, 
$arr)? $arr[1]: false;
   // Recommended interval in seconds to check if the report is ready
   $retryIn = preg_match('/retryIn: (\d+)/', $responseHeaders, $arr)? 
$arr[1]: 60;

if ($httpCode == 400) {

echo " the query Parameters are incorrect or the limit of 
reports in the queue has been reached";
   echo " RequestId: {$requestId}";
   echo " JSON request code:{$body}";
   echo " server response JSON:{$responseBody}";

break;

} elseif ($httpCode == 200) {

echo " Report created successfully";
   echo " RequestId: {$requestId}";
   echo $responseBody;

break;

} elseif ($httpCode == 201) {

echo "the Report was successfully queued in offline mode";
   echo " resend request after {$retryIn} seconds";
   echo " RequestId: {$requestId}";

sleep($retryIn);

} elseif ($httpCode == 202) {

echo " the Report is generated offline.";
   echo " resend request after {$retryIn} seconds";
   echo " RequestId: {$requestId}";

sleep($retryIn);

} elseif ($httpCode == 500) {

echo " an error occurred while generating the report. Please 
try again at < br>";
   echo " RequestId: {$requestId}";
   echo " server response JSON:{$responseBody}";

break;

} elseif ($httpCode == 502) {

echo " report generation time exceeded server limit.";
   echo " Please try to change the query parameters-reduce the 
period and amount of data requested.";
   echo " RequestId: {$requestId}";

break;

} else {

echo " an unexpected error Occurred.";
   echo " RequestId: {$requestId}";
   echo " JSON request code:{$body}";
   echo " server response JSON:{$responseBody}";

break;

}
   }
}

curl_close($curl);

echo $responseBody;


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