<div dir="ltr"><div>se precisarem mais informações, como os dados de headers, requisições, etc, obtidos no acesso via browser eu posso pegar... <br><br></div>Obrigado<br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div>Abraços,<br></div><div>Paulo<br></div></div></div></div></div>
<br><div class="gmail_quote">Em 29 de outubro de 2015 11:03, Paulo Nogueira Starzynski <span dir="ltr"><<a href="mailto:paulons@gmail.com" target="_blank">paulons@gmail.com</a>></span> escreveu:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Pessoal,<br></div>estou desenvolvendo um programa que realiza login em um servidor e depois faz uma requisição POST. estava tudo funcionando bem durante o desenvolvimento até que começou a retornar "Internal Server Error: 500" ao fazer o POST.<br></div>Porém, quando eu acesso via browser, tudo funciona direito.<br><br></div>O fato de funcionar no browser indica necessariamente que o erro é no meu código, certo? devem faltar opções de controle no objeto curl...<br><br></div>Meu código está abaixo, mas infelizmente não é reproduzĩvel porque o acesso ao servido não é público. Mesmo assim, se alguém com familiaridade em curl puder olhar e dar alguma idéia... testei configurar várias opções do curl e nada contronou esse erro 500.<br><br>-----------<br><div><div><div>require(RCurl)
<br> <br>#------------------------------------------<br>curl <- getCurlHandle()
<br>curlSetOpt(
<br>  verbose = T,
<br>  cookiejar = 'cookies.txt' ,
<br>  followlocation = TRUE ,
<br>  ssl.verifypeer = FALSE,
<br>  useragent = 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36',
<br>  curl = curl
<br>)
<br><br>#------------------------------------------<br># list parameters to pass to the website (pulled from the source html)
<br>your.username <- 'usuario'
<br>your.password <- 'senha'
<br>params <-  list( 'txt_email' = your.username,  'txt_senha' = your.password)
<br> <br># Realiza Login no Servidor 
<br>webAddr <- "<a href="http://hostname.br/dirname/ct_login.php" target="_blank">http://hostname.br/dirname/ct_login.php</a>"
<br>login <- postForm(webAddr, .params = params, curl = curl, style = 'POST')
<br>login
<br><br><span style="background-color:rgb(249,203,156)">[1] "1{Sucesso controller{Login efetuado"
<br>attr(,"Content-Type") <br>charset "text/html" "ISO-8859-1"</span> <br><br>#------------------------------------------<br># Realiza Busca
<br>webBuscaId <- "<a href="http://hostname.br/dirname/executa_busca.php" target="_blank">http://hostname.br/dirname/executa_busca.php</a>"
<br>busca <- postForm(webBuscaId, 
<br>                 .opts = list(httpheader = c('Content-Type' = 'application/json', ssl.verifypeer = FALSE)),
<br>                 .params = list('idConsulta' = '13678616F',
<br>                                'adicPar' = 'formatoNulo'), 
<br>                 curl = curl, style="POST")
<br><br>* Hostname was found in DNS cache
<br>*   Trying 10.65.0.169...
<br>* Connected to <a href="http://xxxxxx.xxxxxx.xxx.br" target="_blank">xxxxxx.xxxxxx.xxx.br</a> (10.65.0.169) port 80 (#3)
<br>> POST /xxxxx/executa_busca.php HTTP/1.1
<br>User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36
<br>Host: xxxxx.xxxx.xxx<span style="background-color:rgb(249,203,156)"><span></span></span>.br
<br>Accept: */*
<br>Cookie: PHPSESSID=3dug68beqvmgpe0v19cc78a947
<br>Content-Type: application/json
<br>ssl.verifypeer: FALSE
<br>Content-Length: 28
<br> <br>* upload completely sent off: 28 out of 28 bytes
<br>* HTTP 1.0, assume close after body
<br><span style="background-color:rgb(249,203,156)">< HTTP/1.0 500 Internal Server Error
</span><br>< Date: Thu, 29 Oct 2015 12:53:27 GMT
<br>< Server: Apache/2.2.15 (Red Hat)
<br>< X-Powered-By: PHP/5.3.3
<br>< Expires: Thu, 19 Nov 1981 08:52:00 GMT
<br>< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
<br>< Pragma: no-cache
<br>< Content-Length: 0
<br>< Connection: close
<br>< Content-Type: text/html; charset=ISO-8859-1
<br>< 
<br>* Closing connection 3
<br><span style="background-color:rgb(249,203,156)">Error: Internal Server Error
</span><br>> <span style="background-color:rgb(255,0,0)"><span></span></span><br><br><br><br><div><br clear="all"><div><div><div><div dir="ltr"><div><div>Abraços,<br></div><div>Paulo<br></div></div></div></div></div>
</div></div></div></div></div></div>
</blockquote></div><br></div>