lauryn1298 Posted August 24, 2012 Share Posted August 24, 2012 Hello, I'm working with the curl library of PHP. I'm involved in a project that needs to show the custumers some data of webstites. For getting these contents I use curl and it works very well. Now I have a case I have no idea how to solve, I tried many things but nothing worked until now. The headers are: http://xxxxx/dwr/call/plaincall/ValidacaoCaptchaAction.isValid.dwr POST http://xxxxx/dwr/call/plaincall/ValidacaoCaptchaAction.isValid.dwr HTTP/1.1 Host: www.xxxxx.com User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: pt-br,pt;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Proxy-Connection: keep-alive Content-Type: text/plain; charset=UTF-8 Referer: http://www.xxxxxx.com/proc_result.jsp?yyyy Content-Length: 358 Cookie: JSESSIONID=E3C8250203F7579DF291025B989B6C37; AWSUSER_ID=awsuser_id1345814954804r436; AWSSESSION_ID=awssession_id1345814954804r436 Proxy-Authorization: Basic a2FkdTpra2FkdQ== Pragma: no-cache Cache-Control: no-cache callCount=1 page=/xxxxxx httpSessionId=E3C8250203F7579DF291025B989B6C37 scriptSessionId=935CD798ADD1713369D651C811E2B80E994 c0-scriptName=ValidationAction c0-methodName=isValid c0-id=0 c0-param0=string:63201 batchId=0 My problem is that I don't know how to treat the Content-Type: text/plain; charset=UTF-8, and post the parameters of Cache-Control: no-cache. For the text/plain I add: curl_setopt($this->request, CURLOPT_HTTPHEADER, array('Content-Type' => 'text/plain')); and I tried to post the parameters as: $fields = array( 'callCount'=>'1', 'page' => $url, 'httpSessionId' => $this->cookie_name, 'scriptSessionId' => md5(rand(111111, 999999)), 'c0-scriptName'=>'ValidationAction', 'c0-methodName'=>'isValid', 'c0-id'=>'0', 'c0-param0'=>'string:'.$code, 'batchId'=>'0'); $fields_string = http_build_query($fields); curl_setopt($this->request, CURLOPT_AUTOREFERER, true); curl_setopt($this->request, CURLOPT_HTTPHEADER, array('Content-Type' => 'text/plain')); curl_setopt($this->request, CURLOPT_URL, $url); curl_setopt($this->request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($this->request, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($this->request, CURLOPT_POST,true); curl_setopt($this->request, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($this->request, CURLOPT_HEADER, 0); curl_setopt($this->request, CURLOPT_REFERER, $first_url); curl_setopt($this->request, CURLOPT_FORBID_REUSE, 1); curl_setopt($this->request, CURLOPT_COOKIEJAR, $cookie); curl_setopt($this->request, CURLOPT_COOKIEFILE,$cookie); curl_setopt($this->request, CURLOPT_COOKIESESSION, true); curl_setopt($this->request, CURLOPT_USERAGENT, USERAGENT); $html = curl_exec($this->request); Any ideas what is wrong? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/267525-curl-and-dwr/ Share on other sites More sharing options...
Christian F. Posted August 24, 2012 Share Posted August 24, 2012 Nope, no idea. Primarily because you haven't posted what the actual problem is. Just what you assume to be the reason for it. Also, you haven't said anything about how or why you want to "treat" the two HTTP headers, or even what relevance they have for the actual problem you're seeing. What you have posted is some code that really doesn't tel us anything, but the fact that you're trying to fetch some content from another site. Please read the following article, and adhere to the advice given there: http://www.catb.org/esr/faqs/smart-questions.html#disclaimer PS: Please use the tags around your code, as it helps make both your post and your code a lot easier to read. Quote Link to comment https://forums.phpfreaks.com/topic/267525-curl-and-dwr/#findComment-1372158 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.