Visualizzazione dei risultati da 1 a 4 su 4

Discussione: problema con i domini

  1. #1

    problema con i domini

    Ho fatto questo script, ho un problema tra le variabili $host e $path,dato che il sito in questione utlizza come primo accesso un dominio che inizia con "www",in $path,quando vado a costruire la richiesta post, ho dovuto inserire per intero la parte "http://www1.agenziaentrate.it" che inizia con "www1" invece che con "www",ovviamente,quando lo eseguo,mi da' pagina non trovata (errore http 404).

    Ho evidenziato in rosso le parti di codice di interesse,spero che vi sia una soluzione.

    <?php

    // preconditions

    $port = 80;

    $path = "http://www1 .agenziaentrate.it/servizi/tassazioneattigiudiziari/registrazione.htm";

    $host = "www .agenziaentrate.it";

    $method = "POST";
    $contenttype = "text/html";

    //$data = "passo=0";
    $data = "action=scegliufficio";

    // script
    if($port == 443)
    $sslhost = "ssl://".$host;
    else
    $sslhost = $host;

    //$fp = fsockopen($sslhost, $port);

    echo($sslhost);

    //$fp = fsockopen($sslhost, $port);

    $fp = fsockopen($sslhost, $port, $errorNumber, $errorString);





    if (!$fp)
    {
    echo("Failed opening http socket connection:".$errorString." (" .$errorNumber.")
    \n");
    }


    echo("dopo fsockopen");


    //http://www1.agenziaentrate.it/servizi/tassazioneattigiudiziari/registrazione.htm

    $requestHeader = $method." ".$path ." HTTP/1.1\r\n";
    $requestHeader.= "Host: ".$host ."\r\n";
    $requestHeader.= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0\r\n";
    $requestHeader.= "Content-Type: text/html\r\n";

    if ($method == "POST")
    {
    $requestHeader.= "Content-Length: ".strlen($data)."\r\n";
    }


    $requestHeader.= "Connection: close\r\n\r\n";

    if ($method == "POST")
    {
    $requestHeader.= $data;
    }

    fwrite($fp, $requestHeader);

    echo("dopo fwrite ".$requestHeader);


    $responseHeader = '';
    $responseContent = '';

    do
    {
    $responseHeader.= fread($fp, 1);
    }


    while (!preg_match('/\\r\\n\\r\\n$/', $responseHeader));


    if (!strstr($responseHeader, "Transfer-Encoding: chunked"))
    {
    while (!feof($fp))
    {
    $responseContent.= fgets($fp, 128);
    }
    }
    else


    {echo("non riuscita");

    while ($chunk_length = hexdec(fgets($fp)))
    {
    $responseContentChunk = '';

    echo("debug 01 ".$chunk_length);
    $read_length = 0;

    while ($read_length < $chunk_length)
    {
    $responseContentChunk .= fread($fp, $chunk_length - $read_length);
    $read_length = strlen($responseContentChunk);
    }

    $responseContent.= $responseContentChunk;

    fgets($fp);

    }

    }

    echo("debug AF ".$responseContent);


    echo(" ok 01 ?");


    ?>

  2. #2
    Guarda che $path deve contenere un path (es. /servizi/...), non un URL.

  3. #3
    gia' provato,ma non funziona lo stesso,ecco perche' ho pensato di inserirlo per intero,perche' pensvo di risolvere la discordanza tra "www" e "www1",poi,io ho provato ad inserire un path completo facendo un testo con altri siti e la cosa mi ha funzionato,pur mantenendo pero' lo stesso prefisso "www".

  4. #4
    Se l'URL a cui devi inviare la richiesta POST è http://www1.agenziaentrate.it/serviz...istrazione.htm allora dovrai avere:

    $path = "/servizi/tassazioneattigiudiziari/registrazione.htm";
    $host = "www1.agenziaentrate.it";

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.