TargetingIdeaService v201209: Notice Error: Array to string conversion in /Google/Google/Api/Ads/Common/Lib/AdsSoapClient.php, line 200

249 views
Skip to first unread message

Francisca Munhoz

unread,
Nov 19, 2012, 11:34:18 PM11/19/12
to adwor...@googlegroups.com

Hi Guys,

I'm new to Google API, so I would really appreciate some help here :)

I'm having problem using TargetingIdeaService v201209 with GetKeywordIdeasExample. If I send array like that: 

array_unique(array("smart tv","truck","Ipad","porshe","bmw","fiat","hotels","Iphone","car","Tablet","omega3")); it works fine I can get keywords and category ids back. 

But if I repeat a keyword (car) like that:  

array_unique(array("car","smart tv","truck","Ipad","porshe","bmw","fiat","hotels","Iphone","car","Tablet","omega3"));

Even using array_unique to remove repeated keywords I get this result which only returned the same ids no matter how different the keywords are :

Notice Error: Array to string conversion in [/var/www/sorting-hat/app/Vendor/Google/Google/Api/Ads/Common/Lib/AdsSoapClient.php, line 200]

string(5) "array"
KW: 

array(6) {
  [0]=>
  int(13111)
  [1]=>
  int(10885)
  [2]=>
  int(12197)
  [3]=>
  int(10019)
  [4]=>
  int(12211)
  [5]=>
  int(10168)
}
array(0) {
}


        public function GetKeywordIdeasExample(AdWordsUser $user)
        {
                    $arrKeyword = array_unique(array("smart tv","truck","Ipad","porshe","bmw","fiat","hotels","Iphone","car","Tablet","omega3"));
           $targetingIdeaService = $user->GetService('TargetingIdeaService', 'v201209');
           // Create selector.
           $selector = new TargetingIdeaSelector();
           $selector->requestType = 'STATS';
           $selector->ideaType = 'KEYWORD';
           $selector->requestedAttributeTypes = array('KEYWORD_TEXT','CATEGORY_PRODUCTS_AND_SERVICES');

           // Create related to query search parameter.
           $relatedToQuerySearchParameter = new RelatedToQuerySearchParameter();
           $relatedToQuerySearchParameter->queries = $arrKeyword;
           $selector->searchParameters[] = $relatedToQuerySearchParameter;

           // Set selector paging (required by this service).
           $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
           do {
               // Make the get request.
               $page = $targetingIdeaService->get($selector);

               if (isset($page->entries))
               {
                   foreach ($page->entries as $targetingIdea)
                   {
                       $data = MapUtils::GetMap($targetingIdea->data);
                       $keyword = $data['KEYWORD_TEXT']->value;
                                echo "KW: ". var_dump($keyword) ."\n\n";

                       if (is_array($data['CATEGORY_PRODUCTS_AND_SERVICES']->value))
                       {
                           $categories = $data['CATEGORY_PRODUCTS_AND_SERVICES']->value;
                                    var_dump($categories)."\n\n";

                       }
                   }

               } else {
                   echo "No results\n";
               }

               // Advance the paging index.
               $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
           } while ($page->totalNumEntries > $selector->paging->startIndex);

               $this->out("End:" . date("Y-m-d H:i:s"));
     }  


Thanks in advance!
Fran

Evgeniy Bogdanov

unread,
Nov 22, 2012, 9:48:47 AM11/22/12
to adwor...@googlegroups.com
Hi Fran,

I've tried your code and it gives same result for me. I'm not sure about reasons - seems that problem is in SOAP serialization.

Change to make your code working right:

array_values(array_unique(array("car","smart tv","truck","Ipad","porshe","bmw","fiat","hotels","Iphone","car","Tablet","omega3")));

Regards,
Evgeniy.
Reply all
Reply to author
Forward
0 new messages