longtone Posted September 30, 2009 Share Posted September 30, 2009 I would rather use libCurl than fsockopen, as it seems top be more reliable, but I don't know how to translate some of the headers, especially authorisation headers. eg: //////////////////////////////////////////////////////////////////// //Request Session Token ///////////////////////////////////////////////////////////////////// $proto = "ssl://"; $host = "www.google.com"; $fp = fsockopen( $proto.$host, 443, $errno, $errstr, 120); $page = "/accounts/AuthSubSessionToken"; if ($fp) { $out = "GET $page HTTP/1.1\r\n"; $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= "Host: $host\r\n"; $out .= "Authorization: AuthSub token=\"$token\" data=\"$data\" sig=\"$signature\" sigalg=\"rsa-sha1\"\r\n"; $out .= "User-Agent: Java/1.5.0_06\r\n"; $out .= "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n"; $out .= "Connection: keep-alive\r\n\r\n"; fwrite($fp, $out); // while (!feof($fp)) { for($i=1; $i<=10; $i++) { $output .= fgets($fp, 128) . "<br/>"; } fclose($fp); } I don't know how to include this line using libCurl: $out .= "Authorization: AuthSub token=\"$token\" data=\"$data\" sig=\"$signature\" sigalg=\"rsa-sha1\"\r\n"; The problem with the above script is that for some reason on that url I can only use fgets on the first 10 lines, if I try 11 it freezes up. That was OK, as the info I needed was on line 10, but now another header has been added, and it's on line 11! So if someone could tell me how to rewrite that line using libCurl, or even better, a website that will show me how to translate from fsockopen to libCurl. Or failing that, how to get to line 11 Version: PHP Version 5.2.10 --with-curl=/opt/curlssl/' '--with-curlwrappers' ' Thanks Link to comment https://forums.phpfreaks.com/topic/176037-using-libcurl-indtead-of-fsockopen-i-need-a-translation/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.