Hi - getting frustrated and hoping someone here can help :) Building a simple web app that will call into the API to get current report data. My HTML page calls a PHP script, which uses the PHP "passthru" command to call a Python script, to access the Google API.
If I execute the PHP script from the command line, everything works as expected - the Python script is called, the report is requested, and data is returned and displayed on the page, and the passthru function ends successfully with a return code of 0. But as soon as I call the PHP script from a browser... the Python bombs out, and the passthru ends with a return code of 1 (fail.) Anybody know why? What am I missing here? The PHP and Python scripts are attached. (Note I deleted my login and credentials from the Python script... you'll need to enter your own in if you wish to run this as-is. It's just a cut-up version of one of the samples that generates reports. I manually create the "headers" JSON because I thought it might have been a permissions issue with the .PKL file but it doesn't seem to make a difference.) -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en
<<attachment: test2.php>>
import os
import sys
import time
import urllib2
# Import appropriate constants and classes from the client library.
from adspygoogle.adwords import MIN_API_VERSION
from adspygoogle.common import SOAPPY
from adspygoogle.adwords.AdWordsClient import AdWordsClient
headers = {
'email': 'BLAH',
'password': 'BLAH',
'authToken': 'BLAH',
'clientEmail': 'BLAH',
#'clientCustomerId': '1234567890',
'userAgent': 'DotomiTest',
'developerToken': 'BLAH',
'validateOnly': 'n',
'partialFailure': 'n'
}
config = {
'home': '',
#'home': '/opt/web/htdocs/jptak/google/adwords_api_python_14.2.1/',
'log_home': '',
#'log_home': '/opt/web/htdocs/jptak/google/adwords_api_python_14.2.1/logs/',
#'proxy': 'http://example.com:8080',
'soap_lib': '2',
'xml_parser': '1',
'debug': 'n',
'raw_debug': 'n',
'xml_log': 'n',
'request_log': 'n',
'raw_response': 'n',
'strict': 'y',
'pretty_xml': 'y',
'compress': 'y',
'access': ''
}
#path = '/opt/web/htdocs/jptak/google/adwords_api_python_14.2.1/'
path = ''
# Initialize AdWordsClient object.
#client = AdWordsClient(path=os.path.join('..','google','adwords_api_python_14.2.1'))
#client = AdWordsClient('/opt/web/htdocs/jptak/google/adwords_api_python_14.2.1/')
try:
#client = AdWordsClient(headers, config, path)
client = AdWordsClient(headers)
except:
print 'Login failed!'
exit()
# Option 2: Schedule report job while using library's validation logic.
#
# Construct report job.
job = {
'aggregationTypes': ['Daily'],
'startDay': '2011-09-01',
'endDay': '2011-09-07',
'name': 'Test Campaign Report',
'selectedColumns': ['Campaign', 'CampaignId', 'Impressions'],
'selectedReportType': 'Campaign',
}
# Schedule report and get back report job id.
report_service = client.GetReportService('https://adwords.google.com', 'v13')
report_url = report_service.GetReportDownloadUrl('2183996788')
req = urllib2.Request(report_url[0])
response = urllib2.urlopen(req)
the_data = response.read()
print the_data
