9

I need a very basic interaction example of C# client using some PHP API (A remote service being called from a C# app). I want to see a simple PHP API containing two methods sum(a, b):c and echo(string):string and a simple C# client able to use that methods. How to do such thing?

2
  • What do you mean by PHP API exactly? A remote service being called from a C# app? A c# APP using PHP calls inside the application? Commented Apr 23, 2010 at 20:52
  • A remote service being called from a C# app Commented Apr 23, 2010 at 20:57

3 Answers 3

11

I don't know what you mean by a PHP server but can't you write a script that will add two numbers:

<?php echo (int)$_GET["a"] + (int)$_GET["b"]; ?>

And in C#:

using (var client = new WebClient())
{
    var a = 50;
    var b = 100;
    var result = client.DownloadString(string.Format("http://example.com/add.php?a={0}&b={1}", a, b));
    Console.WriteLine(result);
}

Another and a better option is PHP SOAP.

Sign up to request clarification or add additional context in comments.

1 Comment

look like your PHP SOAP link is dead
1

Create a PHP web service and a C# client defining a proxy to call it.

Comments

0

Have a look at the WebClient Class

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.