HTTP client - How to?
| From: | Bernhard Bock | Date: | Thu, 18 Aug 2005 11:53:25 +0000 |
| Subject: | HTTP client - How to? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-20461@lists.php.net to get a copy of this message | ||
Hi! First: Alexey, i've found this list now, so probably my pm to you is obsolete. Thanks! Ok, here ist my problem. I've been trying to log into a web site and retrieve some data using the HTTP client. But i'm not able to get it running. I guess it has something to do with $defaultRequestParams and $defaultHeaders in constructor. Most probably i don't understand what to do with headers and requestparams. As i haven't found any example that helped to solve this, i'm asking you if there are any good/complete examples available? Thank you! Greetings, Bernhard P.S.: Attached is a test script and its output. It generates an error (german 'Fehler') as if it is not able to login or whatever. Do i have to use some of the listed header array variable? Or do i first have to get the main page 'http://www.knoma.it'? I will keep trying... --- This is a test script: set_include_path() */ // Any pear file has to start with the following line ini_set( 'include_path', '/kunden/physio-bock.de/pear/PEAR' ); // HTTP Client require_once( 'HTTP/Client.php' ); $client = &new HTTP_Client(); $code = $client->post( 'http://www.knoma.it/haendler/main_05.asp', array('UserN' => 'xxxxxx', 'PassW' => 'xxxxxx') ); // remark: i certainly have a working username and password $code = $client->get( 'http://www.knoma.it/haendler/main_30.asp' ); // Display result print_r( $client ); ?> --- And here's the output (save as knoma.htm and view in browser): http_client Object ( [_cookieManager] => http_client_cookiemanager Object ( [_cookies] => Array ( [b79783004e8344baa0eff8ce49857b26] => Array ( [expires] => [domain] => www.knoma.it [path] => / [secure] => [name] => ASPSESSIONIDAACSARBD [value] => GCEHBOCCOOLEDNBHHBKMHCNA ) ) ) [_responses] => Array ( [0] => Array ( [code] => 200 [headers] => Array ( [Connection] => close [connection] => close [Date] => Thu, 18 Aug 2005 10:01:46 GMT [date] => Thu, 18 Aug 2005 10:01:46 GMT [Server] => Microsoft-IIS/6.0 [server] => Microsoft-IIS/6.0 [X-Powered-By] => ASP.NET [x-powered-by] => ASP.NET [Content-Length] => 3031 [content-length] => 3031 [Content-Type] => text/html [content-type] => text/html [Cache-control] => private [cache-control] => private ) [body] =>
Händleranmeldung:
Bitte geben Sie Name und Passwort ein:
Username:
Password:
Falls Sie noch kein Password haben, schicken Sie uns Ihr Firmenpapier mit dem Wunsch um Mitteilung des Passwords an die Nummer: 0039 0471 307150 oder an <mailto:office@knoma.it>office@knoma.it. Wir werden Ihnen dann sofort Ihr persönliches Login und Password mitteilen.
) [1] => Array ( [code] => 302 [headers] => Array ( [Connection] => close [connection] => close [Date] => Thu, 18 Aug 2005 10:01:46 GMT [date] => Thu, 18 Aug 2005 10:01:46 GMT [Server] => Microsoft-IIS/6.0 [server] => Microsoft-IIS/6.0 [X-Powered-By] => ASP.NET [x-powered-by] => ASP.NET [Location] => fehler.asp [location] => fehler.asp [Content-Length] => 131 [content-length] => 131 [Content-Type] => text/html [content-type] => text/html [Cache-control] => private [cache-control] => private ) [body] =>
Object Moved
This object may be found <fehler.asp>here. ) [2] => Array ( [code] => 200 [headers] => Array ( [Connection] => close [connection] => close [Date] => Thu, 18 Aug 2005 10:01:46 GMT [date] => Thu, 18 Aug 2005 10:01:46 GMT [Server] => Microsoft-IIS/6.0 [server] => Microsoft-IIS/6.0 [X-Powered-By] => ASP.NET [x-powered-by] => ASP.NET [Content-Length] => 976 [content-length] => 976 [Content-Type] => text/html [content-type] => text/html [Cache-control] => private [cache-control] => private ) [body] =>
Fehler !!!
Es ist ein Fehler aufgetreten!!!
Bitte versuchen Sie es noch einmal.
Sollte der Fehler mehrmals auftreten, dann bitten wir Sie um eine kurze Verständigung per Email an: <mailto:webadmin@knoma.it>webadmin@knoma.it
) ) [_defaultHeaders] => Array ( [Referer] => http://www.knoma.it/haendler/fehler.asp ) [_defaultRequestParams] => Array ( ) [_redirectCount] => 0 [_maxRedirects] => 5 [_listeners] => Array ( ) [_propagate] => Array ( ) [_isHistoryEnabled] => 1 )