Having a C++ program talk to a php script on a remote server? Possible?

Discussion in 'Programming' started by elum.chaitu, Sep 28, 2010.

  1. #1
    Would it be possible for a C++ program to call for a variable from a remote php script on a server?

    I know PHP from when I was younger, but now in college im taking c++ and I already have a script which checks for a valid license on websites I have designed via php and I was wondering if I could use the same script to make sure c++ compiled programs are also licensed?
     
    elum.chaitu, Sep 28, 2010 IP
  2. mmua

    mmua Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Nothing impossible.
    Just issue HTTP requests for license server and parse reply.
    This can be implemented using raw sockets in a couple of hours, but there are a lot of network libraries around.
     
    mmua, Oct 1, 2010 IP
  3. longcall911

    longcall911 Peon

    Messages:
    1,672
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You want a desktop app to run a PHP code? No. The PHP script runs because a visitor requested the page. So your c++ app would have to emulate a visitor, request a page, then parse the resulting html to find the piece of data you are looking for. That is way too much work to simply determine license status.

    The traditional method is to store license information in a database (mySQL is free) and have either PHP or your C++ app add, delete, modify database records. There are standard c++ tools for communicating with a remote database.
     
    longcall911, Oct 2, 2010 IP
  4. mmua

    mmua Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I vote for accessing HTTP(s) to check license data, since allowing every customer to access database is a bad practice :)
     
    mmua, Oct 4, 2010 IP