Autor | Zpráva | ||
---|---|---|---|
honky tonk Profil * |
#1 · Zasláno: 19. 12. 2013, 09:31:07 · Upravil/a: honky tonk
Četl jsem článek od p. Vrány
http://php.vrana.cz/alternativa-ke-knihovne-curl.php a zkoušel jsem kód <?php // cURL $curl = curl_init("http://php.vrana.cz/"); curl_setopt_array($curl, array( CURLOPT_POST => true, CURLOPT_COOKIE => 'a=1', CURLOPT_POSTFIELDS => array('test' => 'a'), CURLOPT_HEADER => true, CURLOPT_NOBODY => true, CURLOPT_RETURNTRANSFER => true, )); $headers = explode("\r\n", rtrim(curl_exec($curl))); curl_close($curl); // samotné PHP $context = stream_context_create(array('http' => array( 'method' => 'POST', 'header' => 'Cookie: a=1', 'content' => http_build_query(array('test' => 'a')), ))); $fp = fopen("http://php.vrana.cz/", "r", false, $context); $meta = stream_get_meta_data($fp); $headers = $meta["wrapper_data"]; fclose($fp); ?> Bohužel mi to nic neukazuje tak se chci zeptat jak takovou věc rozjet. Jak vytvořit vlastní cookies a následně odeslat požadavek? mělo by print_r($headers); něco vypsat? |
||
honky tonk Profil * |
#2 · Zasláno: 20. 12. 2013, 09:38:12 · Upravil/a: honky tonk
Co znamená a proč se ukazuje tato chyba?
Notice: fopen() [function.fopen]: Content-type not specified assuming application/x-www-form-urlencoded in P:\server\scan_ips\index.php on line 21 Array ( [0] => HTTP/1.1 200 OK [1] => Date: Fri, 20 Dec 2013 08:33:37 GMT [2] => Server: Apache [3] => Connection: close [4] => Content-Type: text/html; charset=utf-8 ) Dozvěděl jsem se, že je třeba specifikovat typ obsahu, ale stále se mi to nedaří otevřít: $context = stream_context_create(array('http' => array( 'method' => 'POST', 'header' => 'Cookie: a=1', 'content' => http_build_query(array('test' => 'a')), 'header' => "Content-Type: application/x-www-form- urlencoded\r\n" ))); Warning: fopen(http://php.vrana.cz/) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in index.php on line 23 A hlavičky: http://paste.ofcode.org/RzXz9T6cQ8tYKtBkiSUXcb O co teda jde? V čem je problém? |
||
Davex Profil |
#3 · Zasláno: 20. 12. 2013, 18:48:51
honky tonk:
Nebude vadit, že je v poli 'http' dvakrát klíč header ?
$headers = array("Cookie: a=1", "Content-type: application/x-www-form-urlencoded"); $context = stream_context_create(array('http' => array( 'method' => 'POST', 'header' => implode("\r\n", $headers), 'content' => http_build_query(array('test' => 'a')), ))); |
||
Časová prodleva: 10 let
|
0