0
我可以使它像这样工作,但那里有一个更好的方法。任何建议?将参数从android传递到Web Api
ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("token", session.getAccessToken()));
HttpParams httpParameters = new BasicHttpParams();
DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
HttpPost httpPost = new HttpPost(URL);
try {
httpPost.setEntity(new UrlEncodedFormEntity(params));
} catch (UnsupportedEncodingException e) {}
httpResponse = httpClient.execute(httpPost);
网络API
[AcceptVerbs("GET", "POST")]
public IHttpActionResult FBToken()
{
string token = ((HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.Params["token"];
//some code
}
我认为当你为你的内涵添加一些解释时,对于OP和更多的访问者会更有帮助。 – reporter 2014-09-19 13:11:56