Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    parser feed rss con fsocketopne

    ciao a tutti,

    nel server dove mi trovo, mi negano l'utilizzo di fopen...

    Mi hanno detto di provare con fsocketopen ma non riesco a venirne fuori, mi da questo errore

    Connessione fallita: 136658444 Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?



    questo il codice utilizzato (ho messo google come prova)


    $host="http://www.google.it/" ;
    $target="";
    $port=8080;
    $timeout=60;
    $protocol="HTTP/1.0" ;

    $br="\r\n" ;

    $sk=fsockopen($host,$port,$errnum,$errstr,$timeout ) ;

    if(!is_resource($sk)){

    exit("Connessione fallita: ".$errnum." ".$errstr) ;

    }

    else{

    $headers="GET ".$target." ".$protocol.$br ;
    $headers.="Accept: image/gif, image/x-xbitmap, image/jpeg".$br ;
    $headers.="Accept-Language: dialetto veneto".$br ;
    $headers.="Host: ".$host.$br ;
    $headers.="Connection: Keep-Alive".$br ;
    $headers.="User-Agent: Socket-PHP-browser 1.0".$br;
    $headers.="Referer: http://www.bwbwabwa.it".$br ;
    $headers.="X-INVENTATO: Ciao a tutti".$br.$br;
    fputs($sk,$headers) ;

    $dati="" ;

    while (!feof($sk)) {

    $dati.= fgets ($sk,2048);

    }

    }

    fclose($sk) ;

    echo($dati) ;

  2. #2
    Ti suggerisco di iniziare leggendo il manuale ufficiale:

    http://www.php.net/fsockopen

    Con particolare attenzione al primo parametro.

  3. #3
    l'esempio funziona ma se lo applico al mio script mi da il solito errore

    // $e_rss equivale ad un file xml esterno

    $xmlParser = xml_parser_create();
    xml_set_element_handler( $xmlParser, "startElement", "endElement" );
    xml_set_character_data_handler( $xmlParser, "charElement" );

    $fp =fsockopen ($e_rss, 80, $errno, $errstr, 30);

    if (!$fp) {
    echo "$errstr ($errno)
    \n";
    } else {
    fputs ($fp, "GET / HTTP/1.1\r\nHost: $e_rss\r\n\r\n");
    while( $data = fread( $fp, 4096 ) )
    {
    xml_parse( $xmlParser, $data, feof( $fp ) );
    }

    }
    fclose ($fp);

    xml_parser_free( $xmlParser );


    il risultato è
    Unable to find the socket transport "http" - did you forget to enable it when you configured PHP? (136658444)

  4. #4

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 © 2025 vBulletin Solutions, Inc. All rights reserved.