Hi Jorge,

>From your other post 
<https://groups.google.com/d/msg/adwords-api/XMjKcLk_Ck4/4KkbLXHb2QsJ> I 
thought you had resolved this issue. Also, when you say you get a "null 
response", do you mean you get a SOAP fault back?

Thanks,
Josh, AdWords API Team

On Tuesday, December 2, 2014 10:53:11 AM UTC-5, Jorge Brasil wrote:
>
> Hi,
>
> I am developing an application that uses the traffic estimation service to 
> get some predictions for the keywords traffic for my company adds.
>
> The issue is that for some keywords that are in one of our campaigns I get 
> a null response from the API, also if I make multiple calls for the same 
> keyword ate some point the response is going to be null.
>
>
> here is my code
>
>
> // Copyright 2014 Google Inc. All Rights Reserved.
> //
> // Licensed under the Apache License, Version 2.0 (the "License");
> // you may not use this file except in compliance with the License.
> // You may obtain a copy of the License at
> //
> //     http://www.apache.org/licenses/LICENSE-2.0
> //
> // Unless required by applicable law or agreed to in writing, software
> // distributed under the License is distributed on an "AS IS" BASIS,
> // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> // See the License for the specific language governing permissions and
> // limitations under the License.
>
> package adwords.axis.v201409.optimization;
>
> import com.google.api.ads.adwords.axis.factory.AdWordsServices;
> import com.google.api.ads.adwords.axis.v201409.cm.Criterion;
> import com.google.api.ads.adwords.axis.v201409.cm.Keyword;
> import com.google.api.ads.adwords.axis.v201409.cm.KeywordMatchType;
> import com.google.api.ads.adwords.axis.v201409.cm.Language;
> import com.google.api.ads.adwords.axis.v201409.cm.Location;
> import com.google.api.ads.adwords.axis.v201409.cm.Money;
> import com.google.api.ads.adwords.axis.v201409.o.AdGroupEstimateRequest;
> import com.google.api.ads.adwords.axis.v201409.o.CampaignEstimateRequest;
> import com.google.api.ads.adwords.axis.v201409.o.KeywordEstimate;
> import com.google.api.ads.adwords.axis.v201409.o.KeywordEstimateRequest;
> import com.google.api.ads.adwords.axis.v201409.o.TrafficEstimatorResult;
> import com.google.api.ads.adwords.axis.v201409.o.TrafficEstimatorSelector;
> import 
> com.google.api.ads.adwords.axis.v201409.o.TrafficEstimatorServiceInterface;
> import com.google.api.ads.adwords.lib.client.AdWordsSession;
> import com.google.api.ads.common.lib.auth.OfflineCredentials;
> import com.google.api.ads.common.lib.auth.OfflineCredentials.Api;
> import com.google.api.client.auth.oauth2.Credential;
>
> import java.util.ArrayList;
> import java.util.List;
>
> /**
>  * This example gets keyword traffic estimates.
>  *
>  * Credentials and properties in {@code fromFile()} are pulled from the
>  * "ads.properties" file. See README for more info.
>  *
>  * Tags: TrafficEstimatorService.get
>  *
>  * Category: adx-exclude
>  *
>  * @author Kevin Winter
>  */
> public class EstimateKeywordTraffic {
> public static ArrayList parameters = new ArrayList();
> public static ArrayList words_param = new ArrayList();
> public static ArrayList bid_values = new ArrayList();
> public static ArrayList copy_bid = new ArrayList();
> private static  List<Money> bids = new ArrayList<Money>();
>   
> /*
> public static void main(String[] args) throws Exception {
>     // Generate a refreshable OAuth2 credential similar to a ClientLogin 
> token
>     // and can be used in place of a service account.
>     Credential oAuth2Credential = new OfflineCredentials.Builder()
>         .forApi(Api.ADWORDS)
>         .fromFile()
>         .build()
>         .generateCredential();
>
>     // Construct an AdWordsSession.
>     AdWordsSession session = new AdWordsSession.Builder()
>         .fromFile()
>         .withOAuth2Credential(oAuth2Credential)
>         .build();
>
>     AdWordsServices adWordsServices = new AdWordsServices();
>
>     runExample(adWordsServices, session);
>   }
> */
>   public static void runExample(
>    
> AdWordsServices adWordsServices, AdWordsSession session) throws Exception {
>     // Get the TrafficEstimatorService.
>  
>   
>   TrafficEstimatorServiceInterface trafficEstimatorService =
>         adWordsServices.get(session, 
> TrafficEstimatorServiceInterface.class);
>
>     // Create keywords. Refer to the TrafficEstimatorService documentation 
> for the maximum
>     // number of keywords that can be passed in a single request.
>     //   
> https://developers.google.com/adwords/api/docs/reference/latest/TrafficEstimatorService
>     List<Keyword> keywords = new ArrayList<Keyword>();
>   
>     keywords.add(new Keyword(null, null, null, "public liability 
> insurance", KeywordMatchType.PHRASE));
>    //keywords.add(new Keyword(null, null, null, "Insurance public", 
> KeywordMatchType.EXACT));
>    //keywords.add(new Keyword(null, null, null, "insurance liability", 
> KeywordMatchType.EXACT));
>    keywords.add(new Keyword(null, null, null, "liability insurance", 
> KeywordMatchType.BROAD));
>
>     int number_of_keywords = keywords.size();
>     
>     bids.clear();
>     bid_values.clear();
>     words_param.clear();
>     parameters.clear();
>     bid_values =  utilities.Bids(number_of_keywords);
>    
>     for(int i = 0 ; i <bid_values.size(); i++ )
>     {
>      
>      Double aux = (Double)bid_values.get(i)*100000;
>      bids.add(new Money(null, aux.longValue()));
>     }
>     
>     
>     // Create a keyword estimate request for each keyword.
>     List<KeywordEstimateRequest> keywordEstimateRequests = new 
> ArrayList<KeywordEstimateRequest>();
>     
>     for (int i = 0 ; i < keywords.size() ; i++) {
>         KeywordEstimateRequest keywordEstimateRequest = new 
> KeywordEstimateRequest();
>         keywordEstimateRequest.setKeyword(keywords.get(i)); 
>         keywordEstimateRequest.setMaxCpc((bids.get(i)));
>         keywordEstimateRequests.add(keywordEstimateRequest);  
>     }
>     
>     // Create ad group estimate requests.
>     List<AdGroupEstimateRequest> adGroupEstimateRequests = new 
> ArrayList<AdGroupEstimateRequest>();
>     AdGroupEstimateRequest adGroupEstimateRequest = new 
> AdGroupEstimateRequest();
>     
> adGroupEstimateRequest.setKeywordEstimateRequests(keywordEstimateRequests
>         .toArray(new KeywordEstimateRequest[] {}));
>   // adGroupEstimateRequest.setAdGroupId(505759692L);
>     
>     adGroupEstimateRequests.add(adGroupEstimateRequest);
>
>     // Create campaign estimate requests.
>     List<CampaignEstimateRequest> campaignEstimateRequests =
>         new ArrayList<CampaignEstimateRequest>();
>     CampaignEstimateRequest campaignEstimateRequest = new 
> CampaignEstimateRequest();
>     
> campaignEstimateRequest.setAdGroupEstimateRequests(adGroupEstimateRequests
>         .toArray(new AdGroupEstimateRequest[] {}));
>     Location unitedStates = new Location();
>     unitedStates.setId(2826L);
>     Language english = new Language();
>     english.setId(1000L);
>     campaignEstimateRequest.setCampaignId(18129492L);
>     campaignEstimateRequest.setCriteria(new Criterion[] {unitedStates, 
> english});
>     campaignEstimateRequests.add(campaignEstimateRequest);
>
>     // Create selector.
>     TrafficEstimatorSelector selector = new TrafficEstimatorSelector();
>     selector.setCampaignEstimateRequests(campaignEstimateRequests
>         .toArray(new CampaignEstimateRequest[] {}));
>
>     // Get traffic estimates.
>     TrafficEstimatorResult result = trafficEstimatorService.get(selector);
>     
>
>     for(int i = 0 ; i < keywords.size();i ++)
>     {
>     
>     Keyword keyword = keywordEstimateRequests.get(i).getKeyword();
>     
>     double minCPC = 
> result.getCampaignEstimates()[0].getAdGroupEstimates()[0].getKeywordEstimates()[i].getMin().getAverageCpc().getMicroAmount();
>     double maxCPC = 
> result.getCampaignEstimates()[0].getAdGroupEstimates()[0].getKeywordEstimates()[i].getMax().getAverageCpc().getMicroAmount();
>     
>     double meanCpc = (minCPC + maxCPC) / 2.0 ;
>     
>     double minAveragePosition = 
> result.getCampaignEstimates()[0].getAdGroupEstimates()[0].getKeywordEstimates()[i].getMin().getAveragePosition();
>     double maxAveragePosition = 
> result.getCampaignEstimates()[0].getAdGroupEstimates()[0].getKeywordEstimates()[i].getMax().getAveragePosition();
>     
>     double meanAveragePosition  =  (minAveragePosition + 
> maxAveragePosition) / 2.0;
>     
>     double minClicks = 
> result.getCampaignEstimates()[0].getAdGroupEstimates()[0].getKeywordEstimates()[i].getMin().getClicksPerDay();
>     double maxClicks = 
> result.getCampaignEstimates()[0].getAdGroupEstimates()[0].getKeywordEstimates()[i].getMax().getClicksPerDay();
>     
>     double meanClicks = (minClicks + maxClicks) / 2.0 ;
>     
>     double minImpressions = 
> result.getCampaignEstimates()[0].getAdGroupEstimates()[0].getKeywordEstimates()[i].getMin().getImpressionsPerDay();
>     double maxImpressions = 
> result.getCampaignEstimates()[0].getAdGroupEstimates()[0].getKeywordEstimates()[i].getMax().getImpressionsPerDay();
>     
>     double meanImpressions = (minImpressions + maxImpressions) / 2.0 ;
>
>  //   System.out.printf("Results for the keyword with text 
> \'%s\':%n",keyword.getText());
>  //   System.out.printf("\tEstimated average CPC: %.2f\n", 
> meanCpc/1000000);
>  //     System.out.printf("\tEstimated ad position: %.2f\n", 
> meanAveragePosition);
>  //       System.out.printf("\tEstimated daily clicks: %.2f\n", 
> meanClicks);
>  //       System.out.printf("\tEstimated daily Impressions: %.2f\n\n", 
> meanImpressions);
>   
>     
>         String [] features  = new String[5];
>         String [] param = new String[2];
>         param[0] = 
> utilities.groupCPC(utilities.truncate(meanCpc/1000000,2));
>         param[1] = 
> utilities.groupPosition(utilities.truncate(meanAveragePosition,2));
>         parameters.add(param);
>
>         features[0] = keyword.getText();
>         features[1] = Double.toString(meanCpc /1000000);
>         features[2] = Double.toString(meanAveragePosition);
>         features[3] = Double.toString(meanClicks);
>         features[4] = Double.toString(meanImpressions);
>         words_param.add(features);
>        
>   
> }
>   }
>   }
>
> I find it strange that the script works for some keywords but don't for 
> others. Can you help me with this matter?
>
> Best 
>
> Jorge 
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/d2966b60-e33c-418c-bc48-f2374d2cf93c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to