Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved]How to call a PHP script on localhost using Qt?

    General and Desktop
    4
    6
    8182
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rishabhc last edited by

      Hello,

      I am developing an app which broadly does the following:

      1. Accepts from the user an html file
      2. Runs a php script to make changes to the html
      3. Returns the changed html back to the user to view

      How can I call the PHP script in Qt? I am using Apache running on my localhost

      1 Reply Last reply Reply Quote 0
      • G
        goetz last edited by

        I would call the PHP command line tool. See the "wiki article":http://developer.qt.nokia.com/wiki/Call_an_AppleScript_from_Qt for an example. It calls the applescript interpreter on OS X, but it's basically the same for the PHP command line tool.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply Reply Quote 0
        • D
          dialingo last edited by

          You can use QNetworkAccessManager to access a page on localhost to trigger the included PHP script. See the documentation of QNetworkAccessManager how you can do this.

          1 Reply Last reply Reply Quote 0
          • R
            rishabhc last edited by

            Thanks. I will try these and post back the progress

            1 Reply Last reply Reply Quote 0
            • 2
              2beers last edited by

              you make a http request to your localhost http server(in your case apache server)
              more info you can find here: "Qt http request":http://wiki.forum.nokia.com/index.php/CS001431_-_Creating_an_HTTP_network_request_in_Qt

              for example you have the following php pahe in your htdocs directory: test.php

              @// test.php
              echo("hello world");
              @

              you just access your page : http://localhost/test.php
              @QUrl url("http://localhost/test.php");
              QNetworkReply* reply = nam->get(QNetworkRequest(url));@

              1 Reply Last reply Reply Quote 0
              • R
                rishabhc last edited by

                Thanks. Using QNetworkAccessManager and QNetworkReply answered the requirement.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post