googleads / googleads-adsense-examples Goto Github PK
View Code? Open in Web Editor NEWSamples for the AdSense Management API
License: Apache License 2.0
Samples for the AdSense Management API
License: Apache License 2.0
Hello, I implemented a project based on the example to generate a report, and in the last week the function stopped working.
I can get the account id, but the following function is not executed
result = service.accounts().reports().generateCsv()
and also no error is returned in the api. Is there any idea how to work around the situation to at least try to identify the error?
The samples here are written for python 2 which is deprecated. The samples also depend on the oauth2client
library which Google also deprecated.
Nevermind, it looks like this is just an example repo and not the actual API am requesting an update for.
As part of Google’s ongoing efforts to foster inclusive language, we’ve changed the default branch of this project to main. We encourage contributors to do the same for their forks and local development environments in order to minimize issues when creating pull requests.
Hello and sorry for submitting an issue about this so directly, but I'm having a lot of issues migrating from v1.4
to v2
in python.
I've followed all of the release note changes and keep getting errors about parameters that are supposedly not supported.
I've tried updating google modules and libraries, but to no avail.
So, is there any effort being done to create the examples for v2
before October 2021 since then the API will be deprecated and reports will be empty.
Hi I'm trying to fetch the ad unit details of an Adsense Account using the Adsense Management API. I created the application on google cloud console and got the client_id and client_secret which I used to get the refresh token as well.
I used the following code snippet to get account id and name:
service = discovery.build('adsense', 'v2', credentials = credentials)
# Retrieve account list in pages and display data as we receive it.
request = service.accounts().list(pageSize=50)
# while request is not None:
result = request.execute()
print(result)
accounts = result['accounts']
for account in accounts:
print ('Account with ID "%s" and name "%s" was found. '
% (account['name'], account['displayName']))
And I was able to get the account name and Id using this , then I further tried to get the ad unit details but I'm getting the mentioned error:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://adsense.googleapis.com/v2/accounts/{account_id}/adclients/{adclient_id}/adunits?pageSize=50&alt=json returned "The caller does not have permission". Details: "The caller does not have permission">
The code snippet I'm using here is:
request = service.accounts().adclients().adunits().list(
parent=f"accounts/{accountId}/adclients/{adClientId}", pageSize=50)
result = request.execute()
Here I'm using the publisher id of the account in the variable - accountId and the customer id in the variable - adClientId.
Am I using the correct IDs? if not from where do I find the ids. If the ids being used are correct then I'm getting this permission error stated above
I have added these scopes as well
https://www.googleapis.com/auth/adsense
https://www.googleapis.com/auth/adsense.readonly
Also I tried the same in the APIs Explorer UI and got the same result
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
What permission do I require here or what can be the solution to get the ad units details for Adsense. I would really appreciate the help as I'm stuck since many days.
In file get_all_custom_channels.py
there is small bug:
while request is not None:
result = request.execute()
custom_channels = result['customChannels']
if 'customChannels' in result:
for custom_channel in result['customChannels']:
If there is no customChannels
in result
it will produce error
.AddMetric and .AddDimension is not working on .NET Framework platform, on .NET Core 5.0 .AddMetric and .AddDimension works well. Would you gimme anoyer solution how to add Metrics and Dimensions to API requset using .NET Framework platform 4.5 and above...
I have been trying to get approved by Google AdSense for wp websites for many months now . I have tried every which way I can think of . I need clear education how to get approved.
List items = apiController.getAdsenseService().accounts().list().execute().getItems();
When I run this command in Android 6.0, it always returns null.
java.lang.IllegalArgumentException: the name must not be empty: null
Running same command in previous version of Android works fine.
Originally posted by @Jabadaba00 in Automattic/legalmattic#26 (comment)
Not only does new Google_Service_AdSense($client)
(in adsense-sample.php) throws an error (because it became Google_Service_Adsense()
), but almost all returned JSON strings/objects and function signatures of most of the other functions in the "Example" classes have been changed and are broken as a result.
My google-fu seems to be pretty weak because I can't seem to find the documentation for the most recent version of the Google ADSENSE Service (only the core Google Service), is there any detailed recent documentation of the Adsense client class(es)/functions?
Thx in advance!
hello,
I want to get the sub-account tree under my current account by account id, get it according to the examples method, and respond to an empty object. In fact, the account has been bound to 7 sub accounts.
$pageToken = null;
$optParams['maxResults'] = 500;
$optParams['pageToken'] = $pageToken;
$result = $this->service->accounts->listAccounts($optParams);
$accounts = null;
if (!empty($result['items'])) {
$accounts = $result['items'];
foreach ($accounts as $account) {
$this->account_id = $account['id'];
}
}
$subAccounts = $this->service->accounts->get($this->account_id, array('tree' => true));
if (!empty($subAccounts['subAccounts'])){
foreach ($subAccounts['subAccounts'] as $account) {
dump($account);
}
}
dd($subAccounts);
response:
Google_Service_AdSense_Account^ {#1363
#collection_key: "subAccounts"
#internal_gapi_mappings: array:1 [
"creationTime" => "creation_time"
]
+creationTime: "1551266190244"
+id: "pub-*********"
+kind: "adsense#account"
+name: "*********"
+premium: false
#subAccountsType: "Google_Service_AdSense_Account"
#subAccountsDataType: "array"
+timezone: "Europe/London"
#modelData: array:1 [
"creation_time" => "1551266190244"
]
#processed: []
}
There is a weird problem if I dump dd($subAccounts,$subAccounts['subAccounts']);
response:
Google_Service_AdSense_Account^ {#1363
#collection_key: "subAccounts"
#internal_gapi_mappings: array:1 [
"creationTime" => "creation_time"
]
+creationTime: "1551266190244"
+id: "pub-*********"
+kind: "adsense#account"
+name: "*********"
+premium: false
#subAccountsType: "Google_Service_AdSense_Account"
#subAccountsDataType: "array"
+timezone: "Europe/London"
#modelData: array:2 [
"creation_time" => "1551266190244"
"subAccounts" => []
]
#processed: array:1 [
"subAccounts" => true // not empty
]
}
Solved the error that occurred when the app starts. App starts, then onCreate is called, then onNavigationItemSelected(..) is called, then refreshView() is called because at this point publisherAccountId is null, which then calls apiController.loadAccounts() which has an invalid credential name because no account name was ever set.
The app was trying to loadaccounts from null user.
Change in MainActivity:
status = AppStatus.GETTING_ACCOUNT_ID;
refreshView();
return true;
To:
chooseDeviceAccount();
return true;
status = AppStatus.GETTING_ACCOUNT_ID;
refreshView();
return true;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.