0

I'm follow How to post JSON to the server? to create method post,but it is not support to window phone.And I have another method post in window phone :

I have string json

string json = "{data : {";
            json += "faceID:\"" + fbID + "\"";
            json += "avatar:\"" + fbAvatar + "\"";
            json += "faceName:\"" + username + "\"";
            json += "commentTime:\"" + cmtTime + "\"";
            json += "content:\"" + cmtContent + "\"";
            json += "articleID:\"" + id + "\"";
            json += "}}";

string url="http://wordpriceder.com/get.php";

Method post json to url .

public static async Task<string> sendJsonData(string url, string json)
    {
        TaskCompletionSource<string> complete = new TaskCompletionSource<string>();

        try
        {
            WebClient wc = new WebClient();
            var URI = new Uri(url);
            wc.Headers["Content-Type"] = "application/json;charset=utf-8";
            wc.UploadStringCompleted += (s, e) =>
            {
                try
                {
                    string tt = e.Result;
                    complete.SetResult(tt);
                }
                catch (Exception exc)
                {
                    complete.SetException(exc);
                }
            };
            wc.UploadStringAsync(URI,"POST", json);
        }
        catch (Exception ex)
        {
            string temp = ex.Message;
        }
        return await complete.Task;
    }

But Json is not pass to url ? so how to do ? or any solution ?

Community
  • 1
  • 1

0 Answers0