本文整理汇总了C#中Hammock.RestRequest.AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C# RestRequest.AddParameter方法的具体用法?C# RestRequest.AddParameter怎么用?C# RestRequest.AddParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hammock.RestRequest
的用法示例。
在下文中一共展示了RestRequest.AddParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fetchXml
public void fetchXml()
{
User = usernamBox.Text.Replace(" ", "").Replace("/", "").Replace(".", "");
URL = new Uri("http://" + User + ".tumblr.com/api/read/json");
int max = 0;
var client = new RestClient();
client.Authority = URL.ToString();
var request = new RestRequest();
request.AddParameter("type", "photo");
request.AddParameter("num", "50");
request.AddParameter("filter", "text");
var r1 = client.Request(request);
var t = r1.Content.ToString().Replace("var tumblr_api_read = ", "");
var firstResponse = JsonParser.FromJson(t);
max = Convert.ToInt32(firstResponse["posts-total"]);
// to eventually make each fetch a separate request
for (int i = 0; i < max; i += 51)
{
if (i != 0)
{
request.AddParameter("start", i.ToString());
}
var r2 = client.Request(request);
var t2 = r2.Content.ToString().Replace("var tumblr_api_read = ", "");
var Response = JsonParser.FromJson(t2);
getUrls(Response.ToDictionary(x => x.Key, x => x.Value));
}
}
示例2: AddComments
public void AddComments(String id, String text, CompleteHandler handler)
{
if (m_netEngine == null)
m_netEngine = new DoubanNetEngine();
RestRequest request = new RestRequest();
request.Method = WebMethod.Post;
request.Path = String.Format("shuo/v2/statuses/{0}/comments", id);
request.AddParameter("text", text);
request.AddParameter("source", DoubanSdkData.AppKey);
m_netEngine.SendRequest(request, (DoubanSdkResponse response) =>
{
if (response.errCode == DoubanSdkErrCode.SUCCESS)
{
DoubanEventArgs args = new DoubanEventArgs();
args.errorCode = DoubanSdkErrCode.SUCCESS;
args.specificCode = response.specificCode;
handler(args);
}
else
{
DoubanEventArgs args = new DoubanEventArgs();
args.errorCode = response.errCode;
args.specificCode = response.specificCode;
handler(args);
}
});
}
示例3: GetFavorites
public RestResponse GetFavorites(string user, int page, int pageSize)
{
// Documentation for GET /favorites
// https://dev.twitter.com/docs/api/1/get/favorites
// Create the REST Client
var client = new RestClient {Authority = "http://api.twitter.com/1"};
// Create the REST Request
var request = new RestRequest {Path = "favorites.json", Method = WebMethod.Get};
request.AddParameter("id", user);
request.AddParameter("page", page.ToString());
request.AddParameter("count", pageSize.ToString());
// Set API authentication tokens
var appSettings = ConfigurationManager.AppSettings;
request.Credentials = OAuthCredentials.ForProtectedResource(
appSettings["ConsumerKey"], appSettings["ConsumerSecret"], appSettings["Token"],
appSettings["TokenSecret"]);
// Make request
var response = client.Request(request);
return response;
}
示例4: BeginUserRealtimeLinks
public void BeginUserRealtimeLinks(BitlyLogin user, RestCallback callback)
{
var request = new RestRequest {Path = "user/realtime_links"};
request.AddParameter("format", "json");
request.AddParameter("access_token", user.access_token);
_sslClient.BeginRequest(request, callback);
}
示例5: BeginGetAccessToken
public void BeginGetAccessToken(string code, RestCallback callback)
{
var oauthClient = new RestClient {Authority = _sslClient.Authority};
//Build an OAuth request manually - the Bit.ly documentation didn't indicate that I needed signatures
var request = new RestRequest {Method = WebMethod.Post, Path = "/oauth/access_token"};
request.AddParameter("client_id", Settings.ConsumerKey);
request.AddParameter("client_secret", Settings.ConsumerSecret);
request.AddParameter("code", code);
request.AddParameter("redirect_uri", Settings.RedirectUrl);
oauthClient.BeginRequest(request, callback);
}
示例6: CreateLoginUsersStatusMessage
/// <summary>
/// ログインユーザのステータスメッセージを更新します
/// </summary>
/// <param name="accessToken"></param>
/// <param name="message"></param>
/// <returns></returns>
public static dynamic CreateLoginUsersStatusMessage(string accessToken, string message)
{
// see http://developers.facebook.com/docs/reference/api/user/
var client = new RestClient { Authority = "https://graph.facebook.com/" };
var request = new RestRequest
{
Path = "me/feed",
Method = Hammock.Web.WebMethod.Post,
};
request.AddParameter("access_token", accessToken);
request.AddParameter("message", message);
var response = client.Request(request);
return DynamicJson.Parse(response.Content);
}
示例7: GetComments
public void GetComments(String id, int count, GetCommentsCompleteHandler handler)
{
if (m_netEngine == null)
m_netEngine = new DoubanNetEngine();
RestRequest request = new RestRequest();
request.Method = WebMethod.Get;
request.Path = String.Format("shuo/v2/statuses/{0}/comments", id);
request.AddParameter("count", count.ToString());
m_netEngine.SendRequest(request, (DoubanSdkResponse response) =>
{
if (response.errCode == DoubanSdkErrCode.SUCCESS)
{
GetCommentsEventArgs args = new GetCommentsEventArgs();
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List<Comment>));
List<Comment> list = ser.ReadObject(response.stream) as List<Comment>;
args.comments = list;
args.errorCode = DoubanSdkErrCode.SUCCESS;
args.specificCode = response.specificCode;
handler(args);
}
else
{
GetCommentsEventArgs args = new GetCommentsEventArgs();
args.comments = null;
args.errorCode = response.errCode;
args.specificCode = response.specificCode;
handler(args);
}
});
}
示例8: UpdateStatus
/// <summary>
/// ステータスを更新します
/// </summary>
/// <param name="accessToken"></param>
/// <param name="accessTokenSecret"></param>
/// <param name="message"></param>
/// <returns></returns>
public static dynamic UpdateStatus(string accessToken, string accessTokenSecret, string message)
{
var client = new RestClient
{
Authority = "http://api.twitter.com",
UserAgent = "OAuthSample",
};
var credentials = OAuthCredentials.ForProtectedResource(
Config.TwitterConsumerKey,
Config.TwitterConsumerSecret,
accessToken,
accessTokenSecret);
credentials.ParameterHandling = OAuthParameterHandling.UrlOrPostParameters;
var request = new RestRequest
{
Path = "statuses/update.json",
Method = WebMethod.Post,
Credentials = credentials,
};
request.AddParameter("status", message);
var response = client.Request(request);
return DynamicJson.Parse(response.Content);
}
示例9: getFacebookData
void getFacebookData()
{
string CallbackUrl = "http://localhost:27393/facebookyeni/callback.aspx";
var client = new RestClient { Authority = "https://graph.facebook.com/oauth/" };
var request = new RestRequest { Path = "access_token" };
request.AddParameter("client_id", ConfigurationManager.AppSettings["FacebookClientId"]);
request.AddParameter("redirect_uri", CallbackUrl);
request.AddParameter("client_secret", ConfigurationManager.AppSettings["FacebookApplicationSecret"]);
request.AddParameter("code", Request["code"]);
RestResponse response = client.Request(request);
StringDictionary result = FacebookConnect.ParseQueryString(response.Content);
string aToken = result["access_token"];
responseFacebookUserInfo(aToken);
}
示例10: SendRequest
public void SendRequest(RestRequest request, RequestBack callBack)
{
Action<string> errAction = (e1) =>
{
if (null != callBack)
{
DoubanSdkErrCode sdkErr = DoubanSdkErrCode.XPARAM_ERR;
callBack(new DoubanSdkResponse
{
//requestID = null != data ? data.requestId : "",
errCode = sdkErr,
specificCode = "",
content = e1,
stream = null
});
}
};
if (null == request)
{
errAction("request should`t be null.");
return;
}
m_Client.Authority = ConstDefine.PublicApiUrl;
m_Client.HasElevatedPermissions = true;
//添加鉴权
request.DecompressionMethods = DecompressionMethods.GZip;
request.Encoding = Encoding.UTF8;
IWebCredentials credentials = null;
if (null != DoubanAPI.DoubanInfo.tokenInfo && !string.IsNullOrEmpty(DoubanAPI.DoubanInfo.tokenInfo.access_token))
{
request.AddHeader("Authorization", string.Format("Bearer {0}", DoubanAPI.DoubanInfo.tokenInfo.access_token));
}
else
{
request.AddParameter("source", DoubanSdkData.AppKey);
}
request.AddParameter("curtime", DateTime.Now.ToString());
request.Credentials = credentials;
m_Client.BeginRequest(request, (e1, e2, e3) => AsyncCallback(e1, e2, callBack));
}
示例11: CreateTokensRequest
protected override RestRequest CreateTokensRequest(NameValueCollection parameters)
{
var request = new RestRequest
{
Path = "/1/oauth2/token.json",
Method = Hammock.Web.WebMethod.Post,
};
request.AddParameter("client_id", SensitiveData.BufferClientId);
request.AddParameter("client_secret", SensitiveData.BufferClientSecret);
request.AddParameter("redirect_uri", callbackUrl);
request.AddParameter("code", parameters["code"]);
request.AddParameter("grant_type", "authorization_code");
return request;
}
示例12: GetUserInformation
/// <summary>
/// ログインユーザ情報を取得します
/// </summary>
/// <param name="accessToken"></param>
/// <returns></returns>
public static dynamic GetUserInformation(string accessToken)
{
// see http://developers.facebook.com/docs/reference/api/user/
var client = new RestClient { Authority = "https://graph.facebook.com/" };
var request = new RestRequest { Path = "me" };
request.AddParameter("access_token", accessToken);
var response = client.Request(request);
return DynamicJson.Parse(response.Content);
}
示例13: CallbackFacebook
public ActionResult CallbackFacebook(string code)
{
if (String.IsNullOrEmpty(code))
{
// TempData is equivalent to flash of rails.
TempData["message"] = "認証に失敗しました";
return RedirectToAction("Login");
}
var client = new RestClient
{
Authority = "https://graph.facebook.com/oauth/",
};
var request = new RestRequest
{
Path = "access_token",
};
request.AddParameter("client_id", Config.FacebookAppId);
request.AddParameter("redirect_uri", Config.ApplicationUrl + "/Account/CallbackFacebook");
request.AddParameter("client_secret", Config.FacebookAppSecret);
request.AddParameter("code", code);
var response = client.Request(request);
// response contains access_token and expires
var result = HttpUtility.ParseQueryString(response.Content);
// to handle expired access tokens, see the blog
// https://developers.facebook.com/blog/post/500/
var accessToken = result["access_token"];
var user = (User)Session["user"] ?? new User();
user.FacebookAccessToken = accessToken;
user.FacebookUser = Facebook.GetUserInformation(accessToken);
Session["user"] = user;
return RedirectToAction("Index", "Tubuyaki");
}
示例14: ApplicationBarIconButton_Click
private void ApplicationBarIconButton_Click(object sender, EventArgs e)
{
string auth_key = String.Format("full_auth_token {0}", settings["me2day_token"]);
IWebCredentials credentials = new BasicAuthCredentials
{
Username = (string)settings["me2day_userid"],
Password = auth_key
};
RestClient client = new RestClient
{
Authority = "http://me2day.net/api/"
};
RestRequest request = new RestRequest
{
Credentials = credentials,
Path = String.Format("create_post/{0}.xml?akey=aed420d038f9b1a7fe3b5c0d94df22f5", settings["me2day_userid"])
};
request.AddParameter("post[body]", WatermarkTB.Text);
request.AddParameter("post[tags]", WatermarkTB2.Text);
if (imgstream != null)
{
request.AddFile("attachment", "image.jpg", imgstream, "image/jpeg");
}
var callback = new RestCallback(
(restRequest, restResponse, userState) =>
{
// Callback when signalled
}
);
client.BeginRequest(request, callback);
MessageBox.Show("Share successfully.", "Thanks", MessageBoxButton.OK);
this.NavigationService.GoBack();
}
示例15: DoRequest
//protected void DoRequest(string sEndpoint, WebMethod wmTransferType, Dictionary<string, string> dssParams, APIReturn aprReturn)
protected void DoRequest(RestRequest rrRequest, OAuthCredentials oaCredentials, APIReturn aprReturn)
{
//suggested by the smart guys at dev.twitter.com
rrRequest.AddParameter("oauth_callback", "oob");
RestClient rcClient = new RestClient
{
Authority = C_OAUTH_BASE_URL,
Credentials = oaCredentials
};
//post request, update credentials object
rcClient.BeginRequest(rrRequest, DoRequestCallback, aprReturn);
}