public function dfp()
 {
     App::import("Vendor", "DFPUser", array("file" => "Google/Api/Ads/Dfp/Lib/DfpUser.php"));
     $path = dirname(__FILE__) . '/../../..';
     set_include_path(get_include_path() . PATH_SEPARATOR . $path);
     try {
         // Get DfpUser from credentials in "../auth.ini"
         // relative to the DfpUser.php file's directory.
         $user = new DfpUser();
         // Log SOAP XML request and response.
         $user->LogDefaults();
         // Get the CreativeService.
         $creativeService = $user->GetCreativeService('v201104');
         // Set the ID of the advertiser (company) that all creatives will be
         // assigned to.
         $advertiserId = (double) '1917';
         // Create an array to store local image creative objects.
         $imageCreatives = array();
         for ($i = 0; $i < 5; $i++) {
             $imageCreative = new ImageCreative();
             $imageCreative->name = 'Image creative #' . $i;
             $imageCreative->advertiserId = $advertiserId;
             $imageCreative->destinationUrl = 'http://google.com';
             $imageCreative->imageName = 'image.jpg';
             $imageCreative->imageByteArray = MediaUtils::GetBase64Data('http://www.google.com/intl/en/adwords/' . 'select/images/samples/inline.jpg');
             $imageCreative->size = new Size(300, 250);
             $imageCreatives[] = $imageCreative;
         }
         // Create the image creatives on the server.
         $imageCreatives = $creativeService->createCreatives($imageCreatives);
         // Display results.
         if (isset($imageCreatives)) {
             foreach ($imageCreatives as $creative) {
                 // Use instanceof to determine what type of creative was returned.
                 if ($creative instanceof ImageCreative) {
                     print 'An image creative with ID "' . $creative->id . '", name "' . $creative->name . '", and size {' . $creative->size->width . ', ' . $creative->size->height . "} was created and\n" . ' can be previewed at: ' . $creative->previewUrl . "\n";
                 } else {
                     print 'A creative with ID "' . $creative->id . '", name "' . $creative->name . '", and type "' . $creative->CreativeType . "\" was created.\n";
                 }
             }
         } else {
             print "No creatives created.\n";
         }
     } catch (Exception $e) {
         print $e->getMessage() . "\n";
     }
 }
 * @author     Paul Rashidi
 */
error_reporting(E_STRICT | E_ALL);
// You can set the include path to src directory or reference
// DfpUser.php directly via require_once.
// $path = '/path/to/dfp_api_php_lib/src';
$path = dirname(__FILE__) . '/../../../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the TeamService.
    $teamService = $user->GetService('TeamService', 'v201408');
    // Set defaults for page and statement.
    $page = new TeamPage();
    $filterStatement = new Statement();
    $offset = 0;
    do {
        // Create a statement to get all teams.
        $filterStatement->query = 'LIMIT 500 OFFSET ' . $offset;
        // Get teams by statement.
        $page = $teamService->getTeamsByStatement($filterStatement);
        // Display results.
        if (isset($page->results)) {
            $i = $page->startIndex;
            foreach ($page->results as $team) {
示例#3
0
 public function checkReportStatus($id)
 {
     $path = dirname(__FILE__) . '/dfp/src';
     set_include_path(get_include_path() . PATH_SEPARATOR . $path);
     require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
     try {
         // Get DfpUser from credentials in "../auth.ini"
         // relative to the DfpUser.php file's directory.
         $user = new DfpUser();
         // Log SOAP XML request and response.
         $user->LogDefaults();
         // Set the ID of the completed report.
         $reportJobId = (double) $id;
         $reportService = $user->GetReportService('v201108');
         $reportJob = $reportService->getReportJob($reportJobId);
         if ($reportJob->reportJobStatus == 'COMPLETED') {
             return true;
         } else {
             return false;
         }
         //  printf("Report downloaded to file '%s'.\n", $filePath);
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }