Im trying to send some data to a php script, the post request is made and I receive a response but the data does not seem to have been received.
C#
public static class Server
{
public static string Adress = "http://ift.tt/1BT5bUt;;
public static async Task<string> SendReport(string subject, string messageTxt, string messageHtml, byte[] attachment)
{
using (HttpClient httpClient = new HttpClient())
{
MultipartFormDataContent content = new MultipartFormDataContent();
if (!string.IsNullOrEmpty(subject))
content.Add(new StringContent(subject), POST.Subject);
if (!string.IsNullOrEmpty(messageTxt))
content.Add(new StringContent(messageTxt), POST.MessageTxt);
if (!string.IsNullOrEmpty(messageHtml))
content.Add(new StringContent(messageHtml), POST.MessageHtml);
if (attachment != null && attachment.Length > 0)
content.Add(new ByteArrayContent(attachment), POST.Attachment);
HttpResponseMessage response = await httpClient.PostAsync(Server.Adress, content);
return await response.Content.ReadAsStringAsync();
}
}
}
static class Program
{
static void Main(string[] args)
{
Console.Write(Server.SendReport("Test", "Message (Text)", "Message (Html)", new byte[] { 0, 1, 0, 1, 1 }).Result);
Console.ReadKey();
}
}
PHP
<?php print_r($_POST); ?>
The PHP-script says that $_POST is an empty array. What am I doing wrong? Im new to web/http interaction and completly new to php..
No comments:
Post a Comment