Can I get simple json response from ads api?

71 views
Skip to first unread message

Ken Hsu

unread,
Jun 27, 2019, 11:19:06 PM6/27/19
to AdWords API and Google Ads API Forum
Hi there.
Can I get simple json response from ads api?
I'm using php sdk.
$googleAdsServiceClient->search($customer_id, $query, ['pageSize' => 1000]);
always return me full object.

Google Ads API Forum Advisor Prod

unread,
Jun 28, 2019, 6:13:53 AM6/28/19
to adwor...@googlegroups.com
Hi Ken,

Could you confirm if my understanding is correct that what you are looking for is how to enable logging so you could see your JSON logs? If yes, you can refer to this PHP guide as to how.

If I misunderstood, could you provide more details so I can better assist you?

Thanks and regards,
Peter
Google Ads API Team

ref:_00D1U1174p._5001UCZwK3:ref

Ken Hsu

unread,
Jul 9, 2019, 11:15:45 PM7/9/19
to AdWords API and Google Ads API Forum
Hi adsapiforumadvisor
It's not about logging.
I want to use json response in my application.
As I know, the sdk always return object from grpc. 
Is there has any functionality to get json response?
something like
$googleAdsServiceClient->searchGetJson($customer_id, $query, ['pageSize' => 1000]);
adsapiforumadvisor於 2019年6月28日星期五 UTC+8下午6時13分53秒寫道:

Google Ads API Forum Advisor Prod

unread,
Jul 10, 2019, 10:47:50 AM7/10/19
to adwor...@googlegroups.com
Hello Ken,

Using client library it is not possible to get the output in JSON format. Alternaltively you an use the CURL operation to get the output in JSON format. Example JSON query is give below.  Please give it a try and let me know if you have any further questions.

CURL example:
curl -H "Authorization: Bearer ACCESS_TOKEN_HERE
       -H "developer-token: DEVELOPER_TOKEN_HERE
       -H "login-customer-id: LOG_IN_CUSTOMER_ID
       -H "Content-Type: application/json" https://googleads.googleapis.com/v1/customers/CLIENT_CUSTOMER_ID_HERE/googleAds:search --data '{query: "SELECT campaign.idcampaign.name, metrics.clicks, metrics.impressions, metrics.conversions, metrics.cost_micros FROM campaign WHERE segments.date DURING LAST_30_DAYS ORDER BY campaign.id"}'

Regards,
Sai Teja, Google Ads API Team

ref:_00D1U1174p._5001UCZwK3:ref

UK Analytics

unread,
Jul 16, 2019, 6:17:14 AM7/16/19
to AdWords API and Google Ads API Forum
Reply all
Reply to author
Forward
0 new messages