Re: Something simple - how do I do this?

2010-11-01 Thread AdWords API Advisor
Hi Tom,

The $selector object must be of type CampaignSelector:

  
http://code.google.com/apis/adwords/docs/reference/latest/CampaignService.CampaignSelector.html

Unfortunately you cannot select on name.  What you can do instead is
select all campaigns and then client side find the one with the
matching name.

Best,
- Eric Koleda, AdWords API Team

On Oct 29, 5:52 am, Tom Armstrong  wrote:
> I want to say 'show the campaign ID for 'campaign X'"
>
> But can't figure it out. Here's my code:
>
> 
> $this_campaign = "Campaign X";
>
> include_once("../scripts/settings.php");
>
> // Set the path
>
> $path = "$DOCUMENT_ROOT/adwords-api/src";
>
> set_include_path(get_include_path() . PATH_SEPARATOR . $path);
>
> // Login section
>
> require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
>
> $user = new AdWordsUser();
>
> // Choose the web service
>
> $campaignService = $user->GetCampaignService();
>
> // Create selector object
>
> $selector = new Campaign();
>
> // Add variables
>
> $selector->name = 'Netbooks';
>
> // Get all campaigns
>
> $page = $campaignService->get($selector);
>
> // Display campaigns
>
> if (isset($page->entries)) {
> foreach ($page->entries as $campaign) {
> $campaign_name = $campaign->name;
> $campaign_id = $campaign->id;
>
> print("$campaign_name - $campaign_id");
>
> }
> }
>
> ?>

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 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


Something simple - how do I do this?

2010-10-29 Thread Tom Armstrong
I want to say 'show the campaign ID for 'campaign X'"

But can't figure it out. Here's my code:

GetCampaignService();

// Create selector object

$selector = new Campaign();

// Add variables

$selector->name = 'Netbooks';

// Get all campaigns

$page = $campaignService->get($selector);

// Display campaigns

if (isset($page->entries)) {
foreach ($page->entries as $campaign) {
$campaign_name = $campaign->name;
$campaign_id = $campaign->id;



print("$campaign_name - $campaign_id");


}
}




?>

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 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