Thanks Jeff!

I've just used include('apility.php');
Should I be including another library as well?

Also, I've included  'Enable_Debug_Mode = yes' in my settings.ini

What else should I add to display the debug messages?

Here's the code I have so far:

<?php

//Works
  // include the APIlity library
  include('apility.php');
  $debug = 1;
  // XOR use data from authentication.ini
  $apilityUser = new APIlityUser();
  // check whether APIlity can be included safely without leaving
traces
  if (session_start()) {
    echo ("Test Session started: " . session_id() . "<br>\n");
  }
  else {
    echo ("Test Session could not be started.<br>\n");
  }
?>

<html>
<body>
 <h3>Sample use of APIlity</h3>
 <small>Using AdWords API <?php echo API_VERSION; ?></small><br /
>&nbsp;<br />
<?php

print_r('start print report');
$printjobs = getAllJobs();

// Display report id for each report.
for ($i = 0; $i < count($printjobs); $i++) {
  $ReportId = $printjobs[$i]['id'];
  echo $ReportId;
  }

// Doesnt Work
  $ReportUrl = getReportDownloadUrl($ReportId);
  echo $ReportUrl;
  echo 'Report id is "' . $printjobs[$i]['id'] . '"';

// Download report. NOT SURE IF THIS IS THE BEST WAY TO DO THIS
                $request_xml =
                  '<getReportDownloadUrl>' .
                  '<reportJobId>' .
                  $ReportId .
                  '</reportJobId>' .
                  '</getReportDownloadUrl>';
                $report_url = $report_service->call
('getReportDownloadUrl',$request_xml);
                $report_url = $report_url
['getReportDownloadUrlReturn'];
                                if ($debug) show_xml($report_service);
                if ($report_service->fault) show_fault($service);

print_r($report_url);

Thanks so much!

Daniel

On Jan 6, 2:04 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
wrote:
> Hello Daniel,
>
>  Those questions are dependent on what SOAP library you're using for
> your AdWords API communications. I'd think that if your getAllJobs()
> call succeeds then you have things properly set up and your
> getReportDownloadUrl() call should succeed as well, but that's not
> necessarily the case.
>
>  Which SOAP library are you using? Have you tried enabling SOAP
> logging in your library and checking the XML that is being sent back
> and received by your code to make sure the getReportDownloadUrl() call
> is being made with the report id parameter and seeing exactly what it
> returns?
>
> Cheers,
> -Jeff Posnick, AdWords API Team
>
> On Jan 6, 3:41 pm, Acapella <daniel_pow...@centerpointe.com> wrote:
>
> > This is great info, thanks very much.
>
> > Also, I'm not getting anything back from getReportDownloadUrl
> > ($ReportId). Do I need to declare the ReportService before I call use
> > getReportDownloadUrl? getAlljobs is working fine though.. Do I need to
> > make $ReportId an integer to make this work?
>
> > Here's an example..
>
> > $printjobs = getAllJobs();
> > print_r($printjobs);
>
> > # Display report id for each report.
> > for ($i = 0; $i < count($printjobs); $i++) {
> >   $ReportId = $printjobs[$i]['id'];
> >   echo $ReportId;
> >   $ReportUrl = getReportDownloadUrl($ReportId);
> >   echo $ReportUrl;
> >   echo 'Report id is "' . $printjobs[$i]['id'] . '"';
>
> > }
>
> > I'm getting closer to getting this working!  Thanks so much.
>
> > Daniel
>
> > On Jan 6, 12:20 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
> > wrote:
>
> > > Hello Dan,
>
> > >  We don't make any guarantees about the order in which the reports
> > > will be returned, so I can't say for certain that the newest is always
> > > returned first. Again, I'd recommend searching through this group's
> > > archives for more discussions about the best way to handle this type
> > > of scenario--there have been several threads.
>
> > >  The cleanest solution is, of course, to just run the report from the
> > > AdWords API directly instead of trying to grab reports that have been
> > > scheduled to run with the AdWords front end, because then you know
> > > exactly which report id you're interested in.
>
> > > Cheers,
> > > -Jeff Posnick, AdWords API Team
>
> > > On Jan 6, 1:45 pm, Acapella <daniel_pow...@centerpointe.com> wrote:
>
> > > > Thanks Jeff!
>
> > > > I get it now. Here's what I came up with..
>
> > > > $printjobs = getAllJobs();
>
> > > > # Display report id for each report.
> > > > for ($i = 0; $i < count($printjobs); $i++) {
> > > >   echo 'Report ID is "' . $printjobs[$i]['id'] . '"';
>
> > > > }
>
> > > > And it returned the Report Ids for each report. (Report ID is
> > > > "675426353"Report ID is "675438683") I only have one report listed and
> > > > one template. Does it include the template as a report too? Also, is
> > > > the first report in the array always the most recent one?
>
> > > > Thanks so much,
>
> > > > Daniel
>
> > > > On Jan 6, 9:17 am, AdWords API Advisor <adwordsapiadvi...@google.com>
> > > > wrote:
>
> > > > > Hello Dan,
>
> > > > >  General information about arrays in PHP can be found at
>
> > > > >  http://us.php.net/types.array
>
> > > > > The getAllJobs() call should return an array of ReportJob objects, and
> > > > > each object has an id property. So you'd want to either iterate
> > > > > through the entire array or access a specific element (if you know in
> > > > > advance which element you're interested in, which you normally
> > > > > wouldn't). Once you have a reference to a given ReportJob object, you
> > > > > can take a look at its id property.
>
> > > > >  If you're looking for a generic PHP example of iterating through an
> > > > > array of data returned from the SOAP service and looking at its
> > > > > properties, lines 62-66 of this might be helpful:
>
> > > > >  http://code.google.com/p/adwords-api-php-samples/source/browse/trunk/...
>
> > > > > Cheers,
> > > > > -Jeff Posnick, AdWords API Team
>
> > > > > On Jan 6, 12:05 pm, Acapella <daniel_pow...@centerpointe.com> wrote:
>
> > > > > > Thanks, Jeff.
>
> > > > > > I've looked everywhere it seems and can't find the syntax on how to
> > > > > > reference the id element in the getalljobs() array. Can you just 
> > > > > > give
> > > > > > me an example, or point me to where it might be? I am new to PHP and
> > > > > > the API and am just using it on this project.
>
> > > > > > Thanks for all your help!
>
> > > > > > Dan
>
> > > > > > On Jan 5, 2:43 pm, AdWords API Advisor 
> > > > > > <adwordsapiadvi...@google.com>
> > > > > > wrote:
>
> > > > > > > Hello Dan,
>
> > > > > > >  There is automatic way to do the mapping. If you search this 
> > > > > > > group
> > > > > > > for some past posts on the subject you can get a feel for what 
> > > > > > > others
> > > > > > > have done and some of the caveats. For example:
>
> > > > > > >  http://groups.google.com/group/adwords-api/browse_thread/thread/b987a...
>
> > > > > > > Cheers,
> > > > > > > -Jeff Posnick, AdWords API Team
>
> > > > > > > On Jan 5, 4:43 pm, Acapella <daniel_pow...@centerpointe.com> 
> > > > > > > wrote:
>
> > > > > > > > Hello,
>
> > > > > > > > I want to download a report programmatically using PHP and I'd 
> > > > > > > > like to
> > > > > > > > schedule it daily to download a report scheduled from the 
> > > > > > > > Adwords Web
> > > > > > > > Page. Is there a straightforward way of doing this? How do I 
> > > > > > > > get the
> > > > > > > > ReportId and JobId for an existing report?
>
> > > > > > > > I was going to use getReportDownloadUrl but it needs the jobId. 
> > > > > > > > I
> > > > > > > > called GetAllJobs which returned an array, but How do I 
> > > > > > > > reference
> > > > > > > > items in that array? I tried GetAllJobs([2]) to get the Report 
> > > > > > > > ID but
> > > > > > > > to no avail.
>
> > > > > > > > Thanks for any help you can give!
>
> > > > > > > > Yours,
>
> > > > > > > > Dan
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to