C# 作为WP8应用程序的论坛
感谢我的英语不好 这是我的问题, 我是第一次用c语言编程,我正在写一个论坛作为一个应用程序,这样你可以看到线程,你可以发布。所以从管理员那里我知道我必须向特定的URL发出Http请求。使用参数:登录名和密码。操作是登录。此外,我还必须保存哈希并在下一个请求中使用它。有人能帮我解决这个问题吗C# 作为WP8应用程序的论坛,c#,windows-phone-8,forum,webrequest,C#,Windows Phone 8,Forum,Webrequest,感谢我的英语不好 这是我的问题, 我是第一次用c语言编程,我正在写一个论坛作为一个应用程序,这样你可以看到线程,你可以发布。所以从管理员那里我知道我必须向特定的URL发出Http请求。使用参数:登录名和密码。操作是登录。此外,我还必须保存哈希并在下一个请求中使用它。有人能帮我解决这个问题吗 namespace PhoneApp8 { public partial class Login{ public async Task<string> SendJSONData(s
namespace PhoneApp8
{
public partial class Login{
public async Task<string> SendJSONData(string https://xxxx.xxxx.xxx, string JSONData)
{
// server to POST to
string url = https://xxxx.xxxxx.xxxxx;
// HTTP web request
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "action";
httpWebRequest.Method = "POST";
// Write the request Asynchronously
using (var stream = await Task.Factory.FromAsync<Stream>(httpWebRequest.BeginGetRequestStream,
httpWebRequest.EndGetRequestStream, null))
{
//create some json string
string json = JSONData;
// convert json to byte array
byte[] jsonAsBytes = Encoding.UTF8.GetBytes(json);
// Write the bytes to the stream
await stream.WriteAsync(jsonAsBytes, 0, jsonAsBytes.Length);
}
WebResponse response = await httpWebRequest.GetResponseAsync();
StreamReader requestReader = new StreamReader(response.GetResponseStream());
String webResponse = requestReader.ReadToEnd();
return webResponse;
}
public partial class MainPage : PhoneApplicationPage
{
// Konstruktor
public MainPage()
{
InitializeComponent();
// Beispielcode zur Lokalisierung der ApplicationBar
//BuildLocalizedApplicationBar();
}
}
你能展示一下你迄今为止所做的尝试吗?您的代码有什么具体问题?@KevinJ我将其添加到我的帖子中,但这都是垃圾。您可能会对OAuth感兴趣:您的代码有什么具体问题?此外,您可以在此处查看使用C登录论坛的示例: