Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Curl e Autenticazione

  1. #1

    Curl e Autenticazione

    Salve, sono nuovo nel forum e vorrei sapere com'è possibile eseguire l'autenticazione su un sito attraverso il curl ed estrarre il contenuto html ( Per precisione il value di un input hidden).
    Il problema è sorto in quanto il sito in questione effettua l'autenticazione ma subito dopo si indirizza su un'altra pagina e sembrerebbe che il curl appunto non funzionasse.


    Questo è lo script utilizzato, le variabili definite le prende da un config.php:
    Codice PHP:
    <?

    // ---------------------------------------------------------------------
    // This file uses CURL to logon to Geovision HTTP web server and then
    // Parse the HTML using the PHP XML parser, return the GUID
    //
    // Written and Copyrighted by: Mythos and Rini
    // Created on: 2010-09-12
    //
    // Required: Geovision version 8.2 
    //           PHP with CURL and GD library installed
    //
    // Notes: Change the Server name, Username, Password in config.php
    // ---------------------------------------------------------------------


    $url 'http://' GN_GEOVISION_CAMERA '/webcam_login'
    $ch curl_init($url);

    //
    // In Geovision HTML form, it takes 2 HTML form elements "id" and "pwd"
    // Also, ImageType = 2 - JPG
    // 

     
    curl_setopt ($chCURLOPT_POST1);
     
    curl_setopt ($chCURLOPT_RETURNTRANSFER1); // return as string instead of showing to screen
     
    curl_setopt ($chCURLOPT_POSTFIELDS"id=" GN_GEOVISION_USER ."&pwd=" GN_GEOVISION_PASSWORD."&ImageType=2");

     
    $output curl_exec($ch);


    //Create a new DOM document
    $dom = new DOMDocument;
     
    //Parse the HTML. The @ is used to suppress any parsing errors
    //that will be thrown if the $html string isn't valid XHTML.
    @$dom->loadHTML($output);
     
    //Get all links. You could also use any other tag name here,
    //like 'img' or 'table', to extract other tags.
    $nodes $dom->getElementsByTagName('title');
     

    $nodeListLength $nodes->length// this value will also change

    $node $nodes->item(0);

    // Since there should be ONLY one element returns, that's the GUID
    $geo_guid $node->nodeValue;


    // Close handle
    curl_close($ch);

    ?>

  2. #2
    Allora, nessun sa la soluzione? (Se c'è..)

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.