2017-12-18 4 views
-5

이 사이트의 Curl을 사용하여 자동으로 로그인하려고 시도하고 있습니다 : https://online.hinode.com.br이며 컨설턴트 ID는 자동으로 항상 같은 상태로 채워 져야합니다. 로그인 후 특정 제품 페이지로 리디렉션되어야합니다. 그러나 테스트 한 코드는 아무데도 가지 않았습니다! 오류 없음, html이로드되지 않습니다.이 선택 필드 여야한다고 생각합니다. 잘 모르겠습니다.입력란 중 하나 인 Curl을 통한 자동 로그인

코드 :

<?php 
// Start cURL 
$ch = curl_init(); 
// Define the original URL (of the login form) 
curl_setopt($ch, CURLOPT_URL, 'https://online.hinode.com.br/'); 
// Enable POST protocol 
curl_setopt ($ch, CURLOPT_POST, 1); 
// Define the parameters that will be sent (user and password for example) 
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'loja_consultor=fulano&estado=SP'); 
// Imitate the boss behavior of browsers: handle cookies 
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 
// Set the transfer type (Padrão: 1) 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
// Execute the requisition 
$store = curl_exec ($ch); 
// Define a new URL to be called (after login) 
curl_setopt($ch, CURLOPT_URL, 'https://online.hinode.com.br/detalhes.asp?IdProduto=769&ssp=830852727SSP20171218HP115020'); 
// Execute the second request 
$content = curl_exec ($ch); 

// 닫기 컬 curl_close ($ ch를);

미리 감사드립니다. enter image description here

enter image description here

+0

Downvoting 영어로없는 때문. – pepperjack

+0

메인 스택 오버 플로우 사이트에 관한 질문은 영어로해야합니다. [pt.so]를 시도하십시오. – jmoerdyk

+0

미안 해요, 스택에 여기 도움을 찾고 있어요. –

답변

0

이 작동 enter image description here

enter image description here :

<?php 
$cookie="cookie.txt"; 
$login_url = "https://online.hinode.com.br/loja_valida.asp"; 
$target_url="https://online.hinode.com.br/detalhes.asp?IdProduto=1294&ssp=1044632862SSP20171218HP180256"; 
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; 

$field['loja_consultor'] = '228621'; 
$field['estado'] = 'SP'; 
$field['acessar'] = 'Acessar'; 

$datafield = http_build_query($field); 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); 
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); 
curl_setopt($ch, CURLOPT_URL, $login_url); 
curl_setopt ($ch, CURLOPT_USERAGENT, $useragent); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datafield); 
curl_setopt ($ch, CURLOPT_POST, 1); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 

curl_exec($ch); 

curl_setopt($ch, CURLOPT_URL, $target_url); 
$ket_qua = curl_exec($ch); 

echo $ket_qua; 

curl_close($ch); 
?> 
+0

Tks,하지만 이것을 시도 할 때 여기에서 발생합니다 : https://i.stack.imgur.com/TmDBs.png –

+0

사이트로 이동하여 정상적으로 로그인하면 예상대로 작동합니까? – tbedner

+0

이미지는 인덱스 페이지에 302 개의 빨간색 텍스트가 나타나는 것을 보여줍니다. – tbedner