[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

How PHP Script Send results to a Desktop Program ?

Hello ,

i design a program using C# (as Desktop Based Program)  and PHP (Web Based Program)

the idea of the program is as following :

the user have the Application in his machine ( .EXE Application ) , and when he run the program , he have to enter the user name and the password , then the Application will send these information to .PHP File on the website ,

the PHP File will check for the validity of this information in the DB , and will respond by yes or no (correct or not correct) !

My Question is : how can i respond the answer to an application on the user machine using PHP ,

in another word , what should i use to send the information from the webserver applications (PHP Application) , to User Machine application (Windows Application -.EXE- )

Note : i need to send the results in XML File to be will structured , how can i do it

Thanks ,
0
BinaryTree
Asked:
BinaryTree
2 Solutions
 
Jaime OlivaresCommented:
I guess you just have to store information in an specific page, so, call the PHP page, generate the XML file, an optionally  return the page address in the generated page by PHP.
0
 
BinaryTreeAuthor Commented:
Hello jaime ,

ok , when a request is sent to the php page from Windows Application (For example : login.php?username=hi&password=hi)  

i want the PHP Application to respond to the client who use the Windows Application with yes or no , exactly like MSN Messenger , when you try to logged in incorrectly , you will get a message from the server to your application to let you know that you enter wrong informations !!

i want to use XML File to exchange the data from my Windows Application to PHP Application and vice versa ! or any other technology , it is not very important to use XML but i think it is the best way ?

how can i solve this problem ?

0
 
SkonenCommented:
I'm not to familiar with C#, but in all the other Microsoft influenced languages like C/C++, you can simply connect to the pages address login.php?username=hi&password=hi and read the content returned. I don't think it can get any simpler than that.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Jaime OlivaresCommented:
I agree with Skonen, just have to read returning html code generated by PHP. As I mentioned, when calling the login or any other query page, just have to read the returning page text.

But, why not to do all in PHP? I think could be easier and cleaner.
0
 
Jaime OlivaresCommented:
If you are working with .NET Platform and want to exchange XML information, then I recommend you to learn about SOAP:
http://www.codeproject.com/soap/laymansoap.asp
http://www.codeproject.com/soap/bubbly.asp
http://www.codeproject.com/soap
0
 
BinaryTreeAuthor Commented:
Hello ,

I think i did not describe my problem will !!


Imagine the following scence :

1- You open your MSN Messenger

2- You enter your username and password incorrectly

3- your Messenger Application send the information to the server (that is use .aspx files for example)

4- the server do checking with your information , then it will find that the user name or password is not correct !

5-the server (.aspx file) send a message to your machine with error number and a string that describe the error

6-Your Messenger (that is exist in your machine) receive the message (in XML Structure or whatever) and display it with Windows Form Dialog Box !


my problem exist in Step # 5 , how can i do this thing (but in PHP)


i hope that it is clear now :)

Thanks all

0
 
Jaime OlivaresCommented:
PHP produces HTML pages, most based in arguments passed in address or through an HTML form. The result is an HTML page, whatever you want.
As you mentioned you use C# in your client side, you have only to invoke a PHP page and read the results, result could be a pure HTML file, or with XML info inside, this doesn't matter.
Then your problem is reduced to **PARSE** HTML 'source code' returned by PHP page.

0
 
Jaime OlivaresCommented:
0
 
BinaryTreeAuthor Commented:
Dear  jaime_olivares ,

this way is not too much Efficient  , because there is problems of Synchronization

imagine if the server is a little bit lagged , so generating this HTML Page will take time (maybe several second) , so the client application will try to read the HTML file that is still not exist because it is not generated yet by the Server !!

also there is a very secret information that i want to send it from the server to the client direct , so i can not put this information in HTML Files in the server , any begginer hacker can access to these file (Because it is plain HTML Files saved in known non - secure )directory ) !!

i read alot about XML-RPC and SOAP in PHP , is these technology can solve my problem , and how ( all the examples that i read in XML-RPC and SOAP , use PHP as the Client and Server Applications , i did not read any example show that it is possible to communicate between diffrent Platforms using diffrent Programming Languages ! )



Thanks ,



0
 
Jaime OlivaresCommented:
>this way is not too much Efficient  , because there is problems of Synchronization
>imagine if the server is a little bit lagged , so generating this HTML Page will take time (maybe several second) , so the client
> application will try to read the HTML file that is still not exist because it is not generated yet by the Server !!
No synchronization error possible, because the client application will wait up to page completion and inform you by any flag or callback function.

>also there is a very secret information that i want to send it from the server to the client direct , so i can not put this
> information in HTML Files in the server , any begginer hacker can access to these file (Because it is plain HTML Files saved
> in known non - secure )directory ) !!
This is the same problem in HTML, XML or whatever, just have to CYPHER your data first, or to use a secure protocol like SSL.

> i did not read any example show that it is possible to communicate between diffrent Platforms using diffrent Programming Languages !
Of course you can, in you can communicate with ANY programming language's application through the Internet, with the appropiate format.

 
0
 
Jaime OlivaresCommented:
I have posted you many links for SOAP clients, it is not important who is the server (PHP, ASP, etc.)
0
 
BinaryTreeAuthor Commented:
Dear jaime_olivares , Thanks for your interesting ,,

you said : " No synchronization error possible, because the client application will wait up to page completion and inform you by any flag or callback function. "

now that is the point , if i can inform the client about the page completion by a flag or a callback function , then i can send an information back to the client directly and that is what i want ... i need the PHP Script to send an information to the Client Program (which is in our case is Windows-Based Application )

i real alot about SOAP , and XML-RPC in PHP , but i see that in all examples the client and the server is a PHP Scripts . what should i change to let the client is Windows Based Application and the server is PHP Application or vice versa ..

for example , the following code is SOAP Client Creating in PHP .. :

$soapclient= new soapclient('http://localhost/soap_server.php') ;


in my case , the receiver of the information is not a PHP Script , it is a windows based application , so can i put the IP Address of the machine that is run the Application instead of 'http://localhost/soap_server.php'  ??? if not what can i do then to send the information to the Windows Based Application from Web Based Application (PHP Application)


Thanks alot :)

0
 
Jaime OlivaresCommented:
>... i need the PHP Script to send an information to the Client Program
Please understand me, you don't have a script to SEND info, just write an HTML page as usual, your client software just have to parse this result page.

> but i see that in all examples the client and the server is a PHP Scripts
Here are examples of SOAP clients with Visual C++, no matters if SOAP server is PHP or any other:
http://www.codeproject.com/soap/vcrope.asp
http://www.codeproject.com/soap/calc_eg.asp
http://www.codeproject.com/soap/VSOAPClient.asp

>in my case , the receiver of the information is not a PHP Script , it is a windows based application , so can i put the IP
> Address of the machine that is run the Application instead of 'http://localhost/soap_server.php'  ??? if not what can i do then
 >to send the information to the Windows Based Application from Web Based Application (PHP Application)
You don't need the IP or name of client application, just fill HTML page as usual (or maybe a TXT or a XML page, doesn't makes difference)


0
 
BinaryTreeAuthor Commented:
Hello jaime_olivares

I know that i can get the result as HTML or XML by parsing the result of the requested page , for example if i call this page :

login.php?username=xxx & password=yyy

then the requested page will generate a HTML Code that i can read it from my windows based program and then i can parse it to get the result ...

I know that i can follow this method , but i need to know how can i use SOAP or XML-RPC with to diffrent Programming Languages , one is PHP , and the other is C#

from the side of the C# Program i have no problems because i just have to listen and wait for the information and i didnt send any thing

but from PHP Side , i have to send the information (or call a remote procedure)  , i see that all examples put  a Path to PHP script that will receive the information like the following code :


soapclient('http://localhost/soap_server.php') ;  

what if my receiver of this information (or the program that i will cal its function ) is not PHP Application , it is C# Application located in a machine that is connected to the web , is it as simple as replacing the URL in 'soapclient' function by IP address of the one who is connected to the web and call the Login Page !!!!!!!!

that is all what i want to know

Thanks :)



0
 
Jaime OlivaresCommented:
>what if my receiver of this information (or the program that i will cal its function ) is not PHP Application , it is C# Application
> located in a machine that is connected to the web , is it as simple as replacing the URL in 'soapclient' function by IP address
> of the one who is connected to the web and call the Login Page !!!!!!!!
The message in soap is an XML files, then NO MATTERS which language is sender and which receiver, just matters that both will handle a XML file. THAT'S THE BEAUTY OF SOAP!!!!
About using an URL or an IP address, doesn't matters too.

0
 
BinaryTreeAuthor Commented:
Hello  jaime_olivares

Ok , that is mean if i replace the URL in the soapclient function by IP i will get a valid result .


notice that the URL is the location for specific file , but the IP is the address for a whole machine , i did not specify the port , and i did not specify the exact program that i want to talk with !!!!


Thanks

0
 
basiclifeCommented:
Ok, I may be coming at this from the wrong side but...

PHP script: http://www.yourserver.com/login.php

Pass it un/password ie use C# to access the page http://www.yourserver.com/login.php?un=username&pass=password

<?php
//login.php
if($_GET['un'] = "test" && $_GET['pass'] = "test2") {
    print "OK";
} else {
    print "Failed";
}
?>

obviously you need to update the if() statement to check with the database you have

When c# loads the page (passing the username/pass in the URL) it'll eaither see "OK" or "Failed" which it can the use to pop up a "your login has failed" box or anything else.

The point is, PHP doesn't know (or care) what sort of software it's talking to. Anyone else seeing the page from on the internet will only see "Failed" (unless they guess a correct username/password).

You can make this a bit more secure by using SSL / some other encryption on the connection so nobody can see the password on the way out but the principle holds true.

This is less a PHP question and more a C# question. All you need to do is read the specified page into C# (which I know ery little about, so I can't help there).

As to IP address / port / etc... DNS lookups should happen in the background to work out the IP address from the host name and the port will be 80 as you're talking to a web server.

C# Pseudo-Code:
=========================
checklogin = Open URL (http://www.yourserver.com/login.php?un=test&pass=test2)
if checklogin = "OK"
        allow client to continue
else
        tell client login failed
endif
=========================

The Open URL function should wait until the page has downloaded before allowing the script to continue so there's no need to open ports / connections to scripts.
0
 
BinaryTreeAuthor Commented:
Actually no one Know what i am talking about , i am talking about Web Services , which let the server excute Procedures in the client side , by using SOAP or XML-RPC ... and my Question was how to let the PHP Script talk directly to C# Application in the client machine and excute procedure on it ( on the client machine that use the c# application) , for sure in this case i have to use SOAP or XML-RPC , but i did not find any article or tutorial that show how to do this kind of interaction (From PHP To Win32 Application in the user machine )


Any way , i will try to ask my question in another Forum , thanks you all

and i will Split the points between jaime_olivares &  basiclife  

Thank you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now