Redirecionar
Eu tenho este JS que faz autenticacao no ML e direciona os dados via parametro para um url minha,
porém a parte "HEADER(location:" nao funciona
https://mercadointegra.com.br/ml.php
<script>
function LerCookie(strCookie){
var strNomeIgual = strCookie+"=";
var arrCookies = document.cookie.split(';');
for(var i=0;i<arrCookies.length;i++){
var strValorCookie = arrCookies[i];
while(strValorCookie.charAt(0) == ' '){
strValorCookie = strValorCookie.substring(1, strValorCookie.length);
}
if(strValorCookie.indexOf(strNomeIgual) == 0){
return strValorCookie.substring(strNomeIgual.length, strValorCookie.length);
}
}
return null;
}
function GerarCookie(strCookie,strValor,lngDias){
var dtmData = new Date();
if(lngDias){
dtmData.setTime(dtmData.getTime() + (lngDias*12*60*60*100));
var strExpires = "; expires=" + dtmData.toGMTString();
}else{
var strExpires = "";
}
document.cookie = strCookie+"="+strValor+strExpires+"; path=/";
}
function ExcluirCookie(strCookie){ GerarCookie(strCookie, '', -1); }
var url=window.location+"=";
var url_hash=window.location.hash;
if (url_hash.length > 0){
var hash=url_hash.substring(url_hash.indexOf("#")+1);
window.location.href="/ml.php?"+hash;
}
else if (url.indexOf('access_token=') != -1){
alert('TESTA SE ENTROU NA FUNCAO')
<?php
if (isset($_REQUEST['access_token'])){
header('Location: http://app.mercadointegra.com.br/ambiente.dll/$/start?ml_acctok='.$_REQUEST['access_token'].'&ml_refrestok='.$_COOKIE['code81722'].'&ml_userid='.$_REQUEST['user_id'].'&ml_expires='.$_REQUEST['expires_in']);
}
?>
}else if (url.indexOf('code=') != -1 && url_hash.length == 0){
ExcluirCookie('code81722');
var code = <?php if (isset($_REQUEST['code'])) print "'$_REQUEST[code]'"; else print '0'; ?>;
GerarCookie('code81722',code,'1');
window.location="https://auth.mercadolibre.com.ar/authorization?response_type=token&client_id=4851093312254197";
}else if (url.indexOf('code=') == -1 && url_hash.length == 0){
window.location="https://auth.mercadolibre.com.ar/authorization?response_type=code&client_id=4851093312254197";
}
</script>Discussão (1)
Carregando comentários...