• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 460
  • Last Modified:

API version is no longer supported - adwords API

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
Pedro Chagas
Asked:
Pedro Chagas
  • 3
  • 2
3 Solutions
 
Pedro ChagasWebmasterAuthor Commented:
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
 
webvogelCommented:
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
 
Pedro ChagasWebmasterAuthor Commented:
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
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
Pedro ChagasWebmasterAuthor Commented:
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now