Jump to content

Erro: This call to PrestaShop Web Services returned an unexpected HTTP status of:301


Recommended Posts

Eu estava trabalando com o servidor local e não tive nenhum problema, tudo estava certo. Mas quando paseis os meus scripts ao servidor me deu o seguinte erro:

Fatal error: Uncaught exception 'PrestaShopWebserviceException' with message 'This call to PrestaShop Web Services returned an unexpected HTTP status of:301'  in /var/www/vhosts/xxx.com/httpdocs/central/scripts/PSWebServiceLibrary.php:96 Stack trace: #0 /var/www/vhosts//xxx.com/httpdocs/central/scripts/PSWebServiceLibrary.php(298): PrestaShopWebservice->checkStatusCode(301) #1 /var/www/vhosts//xxx.com/httpdocs/central/scripts/actualizaweb.php(142): PrestaShopWebservice->get(Array) #2 /var/www/vhosts//xxx.com/httpdocs/central/scripts/actualizaweb.php(24): getProductByEan('0175190') #3 {main} thrown in /var/www/vhosts//xxx.com/httpdocs/central/scripts/PSWebServiceLibrary.php on line 96

 

Eu tenho o prestashop 1.6.0.1, porque pode ser?

Alguem sabe? o.O

 

obrigada por tudo

 

Link to comment
Share on other sites

O que diz a linha /PSWebServiceLibrary.php on line 96 ??

já encontrei as linhas:

		$error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.';
		switch($status_code)
		{
			case 200:	case 201:	break;
			case 204: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'No content'));break;
			case 400: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Bad Request'));break;
			case 401: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Unauthorized'));break;
			case 404: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Not Found'));break;
			case 405: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Method Not Allowed'));break;
			case 500: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Internal Server Error'));break;
			default: throw new PrestaShopWebserviceException('This call to PrestaShop Web Services returned an unexpected HTTP status of:' . $status_code);
		}
	}

ou seja se o serviço encontrar um erro devolve o código HTTP acima definido.

 

e

	return self::parseXML($request['response']);

Presumo que o seu servidor tenha cURL instalado e ativado para que o serviço web funcione ?

 

Agora só falta ler as outras linhas que estao indicando erro... Qual é o código das outras linhas dos ficheiros que mencionou ?

Edited by selectshop.at (see edit history)
Link to comment
Share on other sites

HTTP 301 é um redirecionamento.

 

Pode ser que a reescrita de URLs esteja incorreta (tente gerar um novo arquivo .htaccess).

Ou pode estar direcionando para o endereço errado (normalmente o webservice responde no endereço http://www.sualoja.com.br/api/).

 

Recomendo também desativar o modo debug quando estiver trabalhando com webservice em produção, pois uma chamada da API pode ser interrompida por um aviso (warning / notice), que só aparecem se o modo debug estiver ligado.

 

Boa sorte

  • Like 1
Link to comment
Share on other sites

As linhas que tem erro:

                                                                               // este é o ean inteiro que mando por GET --> 0003305000175190

$ean_prod = substr($_GET['ean'], -7);
                                                                              // esta é a linha 24 (os meus ean são de 16 digitos, mas os sete ultimo são o id do produto que é o que guardo no ean)
$id_prod = getProductByEan($ean_prod); 
 
 

 

function getProductByEan($ean){
require_once('./PSWebServiceLibrary.php');
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$opt['resource'] = 'products';
$opt['filter']['ean13'] = $ean;      // esta é a linha 142
 
$xml = $webService->get($opt);
 
$resources = $xml->products->children();
if (isset($resources)){
foreach ($resources as $resource)
{
 
return $resource->attributes();
}
}else{
return null;
 
}
}
Edited by gamdev (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...