How to contact a server url and retrieve the answer is a string



  • I want to contact a server via http and it returns me a string

    How can I do that?



  • Firefox, IE, Chrome & Safari
    Or you can try to search http in Qassistant --> QHttp



  • I want to take a url like http://nom_machine/pppp.php?code1=valeur1&code2=valeur2
    Once I do that I receive a page with content true or false. That's what I want to get content.

    And if I do this:
    @QNetworkAccessManager manager (this);

    QNetworkRequest request ("http://nom_machine/pppp.php?code1=valeur1&code2=valeur2");
    QNetworkReply * reply = manager.get (request);

    reply-> readAll ();@

    Will reply-> readAll () returns "true" or "false" value that is displayed on the page?



  • Yes but QNAM is asynchronous, so you'll have to use signals/slots (have a look at the examples).



  • Just for the records: QHttp is obsolete. Do not use it in new code - use QNAM instead.

    The code you've posted is a good start. As soon as the request has been finished the finished() signal is emitted and can be used to process the request.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.