Solved

API version is no longer supported - adwords API

Posted on 2009-05-08
6
430 Views
Last Modified: 2013-11-10
Hi E's, about two months ago I install the script you can see in snippet code, that script get variables from google api, and when I install the script work well.
Today I play the script again, and the script don't work, and give me this phrase:
"Fault: 1 Code: soapenv:Server.userException String: The requested version is no longer supported. Please upgrade your application to a more recent version of the API. Detail:".

My knowledge about API's is poor, but I can read something change, and the version of my script no longer work.

The changes are in my code or in the files of nusoap?

I need the help of experts for tell me what kind of changes are, and for help me put the script well again.

Regards, JC
<?

//função para sacar a palha, ou seja todo o palavriado que vem antes das palavras chave

function get_list($string)

{
 

    $matches = array();

    if ( ! preg_match('/[0-9a-f]{32}/i', $string, $matches)) return null;
 

    $hotel_list = substr($string, 32 + strpos($string, $matches[0]));
 

    $hotel_array = preg_split('/[\s{3}\-?[0-9]+\s{2}\-?[0-9]+\s*/', $hotel_list);
 

    if ( ! trim($hotel_array[count($hotel_array) - 1])) unset($hotel_array[count($hotel_array) - 1]);

 

    return implode(', ', $hotel_array);

}

//////////////////////////////////////FIM DE FUNÇÃ0

function show_fault($service) {

   echo "\n";

   echo 'Fault: ' . $service->fault . "\n";

   echo 'Code: ' . $service->faultcode . "\n";

   echo 'String: ' . $service->faultstring . "\n";

   echo 'Detail: ' . $service->faultdetail . "\n";

   exit(0);

 }

//ADQUIRIR VARIAVEIS GET

include ("database.php"); //incluir a base de dados

$vari = $_GET['num']; //obter a palavra que esta a ser analisada

$varinome = $_GET['nome']; //obter a keyword que esta a ser analisada (util p/ identificação na BD)

$palavra = $_GET['wordforapi']; //palavra(s) que vai ser tratada no google adwords

$tamanhos = str_word_count($varinome, 0); //adquire o tamanho da string em palavras
 

//VERIFICAR A EXISTENCIA DA PALAVRA NA BD E VERIFICAR SE ESTA TEM MAIS DE 365 DIAS

if($vari == 0){ //não faz nada 1000

	} else { //irá fazer as verificações quanto á existencia e á data 1000

		//vai á bd buscar ocorrencias para a palavra que está a procurar

		$verif_result = mysql_query("SELECT * FROM pchave where palavra = '$palavra' order by id desc LIMIT 1", $db);

		$verif_rows = mysql_num_rows($verif_result);

		$verif = mysql_fetch_object($verif_result);

			if($verif_rows == 1){ //se existir um registo ele irá verificar se tem mais do que um ano //2000

				//usar $verif->dia para achar a data em conjunto com a função que for apresentada

				$iso = "$verif->dia";

				$now = strtotime('today');

				$old = strtotime($iso);

				$lag = $now - $old;

				$diasdec = $lag / 60 / 60 / 24;

				if($diasdec > 365){ //se tiver mais que um ano nao faz nada e deixa o script continuar//3000

					} else { exit; } //3000

						} else { } //2000

							} //fim de 1000

											

//SE ESTIVER NA KEYWORD INTERIRA OU NO ZERO EXECUTA UM UPGRADE E NÃO UMA INSERÇÃO

if ($vari == 0){ //4000

include('soapclientfactory.php');

$email = '++++++++++++++';

$password = '+++++++++++++++';

$useragent = 'INSERT_COMPANY_NAME: AdWords API PHP Sample Code';

$developer_token = '+++++++++++++++++++++';

$application_token = '++++++++++++++++++++++';

$headers =

  '<email>' . $email . '</email>'.

  '<password>' . $password . '</password>' .

  '<clientEmail>' . $client_email . '</clientEmail>' .

  '<useragent>' . $useragent . '</useragent>' .

  '<developerToken>' . $developer_token . '</developerToken>' .

  '<applicationToken>' . $application_token . '</applicationToken>';

$namespace = 'https://adwords.google.cn/api/adwords/v12';

$keyword_tool_service = SoapClientFactory::GetClient(

  $namespace . '/KeywordToolService?wsdl', 'wsdl');

$keyword_tool_service->setHeaders($headers);

$debug = 1;

$seed_keyword =

  '<negative>false</negative>' .

  '<text>'.$palavra.'</text>' .

  '<type>Exact</type>';

$use_synonyms = '<useSynonyms>true</useSynonyms>';

$request_xml =

  '<getKeywordVariations>' .

  '<seedKeywords>' . $seed_keyword . '</seedKeywords>' .

  $use_synonyms .

  '<languages>pt</languages>' .

  '<countries>PT</countries>' .

  '<countries>BR</countries>' .

  '</getKeywordVariations>';

$variation_lists =

  $keyword_tool_service->call('getKeywordVariations', $request_xml);

$variation_lists = $variation_lists['getKeywordVariationsReturn'];

function show_xml($service) {

  return $service->response;

}

if ($debug) show_xml($keyword_tool_service);

if ($keyword_tool_service->fault) show_fault($keyword_tool_service);

$to_consider = $variation_lists['additionalToConsider'];

($to_consider) .

  ' variation(s).' . "\n";

$more_specific = $variation_lists['moreSpecific'];

($more_specific) .

  ' variation(s).' . "\n";

 //fim do sistema de sacar as keywords

//chama a função para a variavel se tornar global //keywords em bruto

$newwords = show_xml($keyword_tool_service);
 

//chama a função para a variavel se tornar global //saca o cabeçalho

$keykey = get_list($newwords); 

$keykey = strip_tags($keykey); //saca as tags html
 

preg_match_all("/[\sa-zA-Z]+[0-9\-]+\s+[0-9\-]+/", $keykey, $keyslimpas); //transforma cada heyword numa chave de array

$keyslimpas = array_values($keyslimpas[0]); //reorganiza a array

//função para ordenar as keys (ordenadas por procura e não por competividade)

$sort = create_function('$a,$b',

  '$ax=explode(" ",preg_replace("/\s+/"," ",trim($a)));

   $bx=explode(" ",preg_replace("/\s+/"," ",trim($b)));

   $a1=$ax[count($ax)-1];

   $b1=$bx[count($bx)-1];

   if($a1>$b1) return -1;

   if($a1<$b1) return 1;

   $a2=$ax[count($ax)-2];

   $b2=$bx[count($bx)-2];

   if($a2>$b2) 

     return -1*(($a1==-1)?1:-1);

   if($a2<$b2) 

     return 1*(($a1==-1)?1:-1);

   return 0;');

usort($keyslimpas,$sort);

// final de ordenação
 

$keyslimpas = implode(', ', $keyslimpas); //array p string

//echo $keyslimpas;

//faz upgrade á base de dados

mysql_query("update relatorio set adwordszero = '$keyslimpas' where palavra_chave='$varinome'", $db);

echo "acabou de fazer upgrade á base de dados com a frase $palavra";
 

}//4000
 

//CASO SE TRATE DE 1 PALAVRA ELE NAO VOLTA A PEDIR KEYWORDS, INSERE MAS PROVENIENTE DA TABELA RELATORIOS

if($vari == 1 && $tamanhos == 1){ //5000

	//chama a bd para ir buscar a palavra

	$existente_result = mysql_query("SELECT * FROM relatorio where palavra_chave = '$varinome' order by id desc LIMIT 1", $db);

	$existente_rows = mysql_num_rows($existente_result);

	$existente = mysql_fetch_object($existente_result);

	$data = date('Y-m-d'); //data de hoje

	$keysrel = $existente->adwordszero;

	mysql_query("insert into pchave set palavra='$palavra', sugere='$varinome', chaves='$keysrel', dia='$data'", $db);

} //5000
 

//PALAVRAS INDIVIDUAIS CASO A STRING SEJA MAIOR QUE UMA PALAVRA

if($vari > 0 && $tamanhos > 1){ //6000

include('soapclientfactory.php');

$email = '+++++++++++++++++++';

$password = '+++++++++++++++++';

$useragent = 'INSERT_COMPANY_NAME: AdWords API PHP Sample Code';

$developer_token = '++++++++++++++++++++';

$application_token = '++++++++++++++++++++++++++';

$headers =

  '<email>' . $email . '</email>'.

  '<password>' . $password . '</password>' .

  '<clientEmail>' . $client_email . '</clientEmail>' .

  '<useragent>' . $useragent . '</useragent>' .

  '<developerToken>' . $developer_token . '</developerToken>' .

  '<applicationToken>' . $application_token . '</applicationToken>';

$namespace = 'https://adwords.google.cn/api/adwords/v12';

$keyword_tool_service = SoapClientFactory::GetClient(

  $namespace . '/KeywordToolService?wsdl', 'wsdl');

$keyword_tool_service->setHeaders($headers);

$debug = 1;

$seed_keyword =

  '<negative>false</negative>' .

  '<text>'.$palavra.'</text>' .

  '<type>Exact</type>';

$use_synonyms = '<useSynonyms>true</useSynonyms>';

$request_xml =

  '<getKeywordVariations>' .

  '<seedKeywords>' . $seed_keyword . '</seedKeywords>' .

  $use_synonyms .

  '<languages>pt</languages>' .

  '<countries>PT</countries>' .

  '<countries>BR</countries>' .

  '</getKeywordVariations>';

$variation_lists =

  $keyword_tool_service->call('getKeywordVariations', $request_xml);

$variation_lists = $variation_lists['getKeywordVariationsReturn'];

function show_xml($service) {

  return $service->response;

}

if ($debug) show_xml($keyword_tool_service);

if ($keyword_tool_service->fault) show_fault($keyword_tool_service);

$to_consider = $variation_lists['additionalToConsider'];

($to_consider) .

  ' variation(s).' . "\n";

$more_specific = $variation_lists['moreSpecific'];

($more_specific) .

  ' variation(s).' . "\n";

 //fim do sistema de sacar as keywords

//chama a função para a variavel se tornar global //keywords em bruto

$newwords = show_xml($keyword_tool_service);
 

//chama a função para a variavel se tornar global //saca o cabeçalho

$keykey = get_list($newwords); 

$keykey = strip_tags($keykey); //saca as tags html
 

preg_match_all("/[\sa-zA-Z]+[0-9\-]+\s+[0-9\-]+/", $keykey, $keyslimpas); //transforma cada heyword numa chave de array

$keyslimpas = array_values($keyslimpas[0]); //reorganiza a array

//função para ordenar as keys (ordenadas por procura e não por competividade)

$sort = create_function('$a,$b',

  '$ax=explode(" ",preg_replace("/\s+/"," ",trim($a)));

   $bx=explode(" ",preg_replace("/\s+/"," ",trim($b)));

   $a1=$ax[count($ax)-1];

   $b1=$bx[count($bx)-1];

   if($a1>$b1) return -1;

   if($a1<$b1) return 1;

   $a2=$ax[count($ax)-2];

   $b2=$bx[count($bx)-2];

   if($a2>$b2) 

     return -1*(($a1==-1)?1:-1);

   if($a2<$b2) 

     return 1*(($a1==-1)?1:-1);

   return 0;');

usort($keyslimpas,$sort);

// final de ordenação
 

$keyslimpas = implode(', ', $keyslimpas); //array p string
 

$data = date('Y-m-d'); //data de hoje

mysql_query("insert into pchave set palavra='$palavra', sugere='$varinome', chaves='$keyslimpas', dia='$data'", $db);

}//6000

?>

Open in new window

0
Comment
Question by:Pedro Chagas
  • 3
  • 2
6 Comments
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 24344337
Hi E's, This script use 'soapclientfactory.php' to work, and that script call nusoap.php.
Really I don't know if the changes I have to do for the script work are in the code post above or if it is in nusoap's files.
Maybe if I know where is the changes, I can search more easly for a solution (code above or nusoap files????).
Like I said in the first post, my knolgment in API's is poor, and I try saw a solution in adwords API site, but I can't understand where is the change.

The only thing I have certain is my code is no longer supported, so, I just want to know what I have to do for thay work again.

Regards, JC
0
 
LVL 3

Assisted Solution

by:webvogel
webvogel earned 150 total points
ID: 24345587
All I know is, the error is comming from this line:
if ($keyword_tool_service->fault) show_fault($keyword_tool_service);

and $keyword_tool_service is a SoapClientFactory object.
So it is not comming from your code.

With google search I found, it has to do with nusoap:
"I think you should probably be using Apility instead:
http://google-apility.sourceforge.net"
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 24349407
Hi @webvogel, thanks for your opinion about apility, I check and I thing is a good option. I open this new question about apility: http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_24396092.html
If somebody help me in that question maybe I start with apility.

In this question I try to understand why version is no longer supported, about one month ago the script work very well, and after some days they don't work more, it's a stupid thing!

So, I believe have some expert that use adwords API and give me a big help to understand what is wrong in my code.

Regards, JC
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 39

Accepted Solution

by:
Roger Baklund earned 350 total points
ID: 24352643
0
 
LVL 39

Assisted Solution

by:Roger Baklund
Roger Baklund earned 350 total points
ID: 24352665
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 24405893
In my first post in this question I post the code I use to get keywords variations. I read the two articles but they not are conclusive for me, maybe because my knowledge in API and XML is not too mutch.

I just need a example of new version of API, just this, after I get the example maybe I can understand where is the differences.

So, some expert have a example of adword API (for keywords suggestion)?

Regards, JC



0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now