Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 15

Discussione: Traduzione da VB.NET

  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    719

    Traduzione da VB.NET

    Ciao,
    Mi potete tradurre in PHP questo script VB.NET?
    Codice PHP:
    Function GetPage(ByVal url As String)
           
    Dim tempCookies As New CookieContainer
           tempCookies 
    logincookie
           Dim encoding 
    As New UTF8Encoding
           Dim getReq 
    As HttpWebRequest DirectCast(WebRequest.Create(url), HttpWebRequest)

           
    getReq.Method "GET"
           
    getReq.KeepAlive True
           getReq
    .CookieContainer tempCookies
           getReq
    .Accept "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
           
    getReq.UserAgent useragent

           Dim getResponse 
    As HttpWebResponse

           getResponse 
    DirectCast(getReq.GetResponse(), HttpWebResponse)
           
    tempCookies.Add(getResponse.Cookies)
           
    logincookie tempCookies
           Dim getResponseReader 
    As New StreamReader(getResponse.GetResponseStream())

           
    Dim thepage As String getResponseReader.ReadToEnd

           
    Return thepage
       End 
    Function 
    Grazie Mille,
    CIAO

  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    719
    up!

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    719
    Up!

  4. #4

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    719
    Già provato, non va...

  6. #6
    pardo, mi era sfuggito che fai uso di cookie per gestire l'autenticazione

    in questo caso non è così semplice perché devi passare i cookie e per passare i cookie devi utilizzare le CURL

    Qui maggiori informazioni
    www.php.net/curl

    Qui qualche risultato utile
    http://www.google.it/search?sourceid...rl+cookielogin
    The fastest Redis alternative ... cachegrand! https://github.com/danielealbano/cachegrand

  7. #7
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    719
    Si, stavo provando a fare qualcosa...
    Ho trovato questo sempre dallo stesso sito da cui ho preso lo script VB.NET:

    Codice PHP:
    <?php

    error_reporting
    (E_ALL);


    libxml_use_internal_errors(true);
    $fp fopen("curl_log.txt",'a+');  //Logging purposes only

    $dataURL     "https://secure.eu.playstation.com/ajax/mypsn/friend/presence";
    $loginURL     "https://store.playstation.com/external/login.action?returnURL=https://secure.eu.playstation.com/sign-in/confirmation";


    $cc curl_init();

    getData();

    function 
    getData()
    {
       
       global 
    $cc,$fp,$dataURL;
       
       
    curl_setopt ($ccCURLOPT_URL$dataURL);
       
    curl_setopt ($ccCURLOPT_POST0);
       
    curl_setopt ($ccCURLOPT_RETURNTRANSFER1);
       
    curl_setopt ($ccCURLOPT_FOLLOWLOCATION1);
       
    curl_setopt ($ccCURLOPT_USERAGENT'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12');
       
    curl_setopt ($ccCURLOPT_SSL_VERIFYPEER0);
       
    curl_setopt ($ccCURLOPT_REFERER$dataURL);
       
    curl_setopt ($ccCURLOPT_VERBOSE1);
       
    curl_setopt ($ccCURLOPT_STDERR$fp);
       
    curl_setopt ($ccCURLOPT_COOKIEFILE'cookie.txt');

       
    $output curl_exec($cc);

       
    $xml simplexml_load_string($output);

       if (!
    $xml)
       {
           
    login();
       }
       else
       {
           
                  
    // Here you will have a simpleXML object that you can do with as you please - example output below.

                   
    foreach($xml->psn_friend as $friend)
           {
               echo 
    "Name : ".$friend->onlineid."
    "
    ;
               echo 
    "Status : ".$friend->current_presence."
    "
    ;
               echo 
    "Game : ".$friend->current_game."
    "
    ;
               echo 
    "Comment : ".$friend->Comment."
    "
    ;
       
               echo 
    "

    "
    ;
           }
           
           
    curl_close($cc);
           
    fclose($fp);    
       }
    }

    function 
    login()
    {
       global 
    $cc,$loginURL;
       
       
    curl_setopt ($ccCURLOPT_URL$loginURL);
       
    curl_setopt ($ccCURLOPT_POST1);
       
    curl_setopt ($ccCURLOPT_POSTFIELDS'loginName=xxxxx&password=xxxxx');
       
    curl_setopt ($ccCURLOPT_COOKIEJAR'cookie.txt');
       
       
    curl_exec($cc);
       
       
    getData();
    }

    ?>
    Ma su atervista non gira, mi dice:
    codice:
    Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /membri/simonemiraglia/psnAPI/home.php on line 25
    E poi non ho ancora capito bene cosa mettere su "cookie.txt".
    Mi devo informare meglio.

    Comunque grazie.
    CIAO

  8. #8
    devi togliere il curl_setopt che imposta CURLOPT_FOLLOWLOCATION perché sei in safe mode
    The fastest Redis alternative ... cachegrand! https://github.com/danielealbano/cachegrand

  9. #9
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    719
    Ma senza quello non funziona...
    Coma la disabilito su altervista?

  10. #10
    no, senza quello non viene effettuato il redirect automatico, cosa che, in generale non va ad influire sul funzionamento di un sistema di login, tranne che il sistema di login è qualcosa di esotico (ergo fatto male)
    The fastest Redis alternative ... cachegrand! https://github.com/danielealbano/cachegrand

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.