Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]How to call a PHP script on localhost using Qt?

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

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 8.6k Views
  • 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 Offline
    R Offline
    rishabhc
    wrote on last edited by
    #1

    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
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      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
      0
      • D Offline
        D Offline
        dialingo
        wrote on last edited by
        #3

        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
        0
        • R Offline
          R Offline
          rishabhc
          wrote on last edited by
          #4

          Thanks. I will try these and post back the progress

          1 Reply Last reply
          0
          • 2 Offline
            2 Offline
            2beers
            wrote on last edited by
            #5

            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
            0
            • R Offline
              R Offline
              rishabhc
              wrote on last edited by
              #6

              Thanks. Using QNetworkAccessManager and QNetworkReply answered the requirement.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved