/// <summary> /// Gets the user details. /// </summary> /// <remarks> /// <para> /// For more details, please see <see href="https://developers.facebook.com/docs/graph-api/reference/v2.0/user">User</see> method in <b>Guide of Facebook Graph API</b>. /// </para> /// </remarks> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo() { // query parameters var parameters = new NameValueCollection { { "access_token", this.AccessToken["access_token"].ToString() } }; // execute the request var result = OAuthUtility.ExecuteRequest ( "GET", "https://api.github.com/user", parameters, null ); // help: https://developer.github.com/v3/users/#get-the-authenticated-user // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("login", "UserName", typeof(string)); map.Add("name", "DisplayName"); map.Add("email", "Email"); map.Add("html_url", "Url"); //blog map.Add("avatar_url", "Userpic", typeof(DateTime), @"MM\/dd\/yyyy"); // parse the server response and returns the UserInfo instance return(new UserInfo(result.Result as Dictionary <string, object>, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo() { // api documentation: // https://developer.linkedin.com/apis // https://developer.linkedin.com/documents/profile-api // https://developer.linkedin.com/documents/profile-fields // execute the request var result = OAuthUtility.ExecuteRequest ( method: "GET", endpoint: "https://api.linkedin.com/v1/people/~:(id,first-name,last-name,picture-url,email-address)", authorization: String.Format("Bearer {0}", this.AccessToken["access_token"]), headers: new NameValueCollection { { "x-li-format", "json" } } ); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("first-name", "FirstName"); map.Add("last-name", "LastName"); map.Add("picture-url", "Userpic"); map.Add("emailAddress", "Email"); // parse the server response and returns the UserInfo instance return(new UserInfo(result.Result as Dictionary <string, object>, map)); }
/// <summary> /// Gets the user details. /// </summary> public override UserInfo GetUserInfo() { // query parameters var parameters = new NameValueCollection { { "access_token", this.AccessToken["access_token"].ToString() } }; // execute the request var result = OAuthUtility.ExecuteRequest ( "GET", "https://api.amazon.com/user/profile", parameters ); // field mapping var map = new ApiDataMapping(); map.Add("user_id", "UserId"); map.Add("name", "DisplayName"); map.Add("email", "Email"); // parse the server response and returns user info return(new UserInfo(result.Result as Dictionary <string, object>, map)); }
public CloudFiles AddFiles(Dictionary <string, object> items) { UniValue file = UniValue.Create((Dictionary <string, object>)items); var map = new ApiDataMapping(); map.Add("id", "FileID"); map.Add("title", "FileName"); map.Add("fileExtension", "Extention"); map.Add("downloadUrl", "DownUrl"); map.Add("thumbnailLink", "Thumnail"); map.Add("fileSize", "FileSize", typeof(long)); map.Add("modifiedDate", "modifiedDate"); FileInfo fi = new FileInfo(file, map); //fi.Path = "root"; fi.driveinfo = driveinfo; if (fi.Extention != null) { fi.DownUrl = "https://www.googleapis.com/drive/v2/files/" + fi.FileID + "?alt=media"; fi.IsFile = true; } else { fi.Path += fi.FileName + "/"; fi.IsFile = false; } GoogleFile files = new GoogleFile(fi); GoogleFiles.Add(files); return(files); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <param name="usersname">Name of the user whose data should be obtained.</param> public UserInfo GetUserInfo(AccessToken accessToken = null, string usersname = "") { if (String.IsNullOrEmpty("usersname")) { throw new ArgumentNullException("usersname"); } // help: https://sourceforge.net/p/forge/documentation/Allura%20API/#user string url = String.Format("https://sourceforge.net/rest/u/{0}/profile", usersname); this.Authorization["oauth_token"] = this.AccessToken["oauth_token"]; this.Authorization.TokenSecret = this.AccessToken["oauth_token_secret"].ToString(); base.Authorization["oauth_body_hash"] = "2jmj7l5rSw0yVb/vlWAYkK/YBwk="; base.Authorization.Build("GET", url, null, null); // execute the request var result = OAuthUtility.Get(url, base.Authorization.Value.ToNameValueCollection()); // field mapping var map = new ApiDataMapping(); map.Add("username", "UserName"); map.Add("name", "DisplayName"); map.Add("url", "Url"); // parse the server response and returns the UserInfo instance return(new UserInfo(result["developers"][0], map)); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Get ( "https://api.github.com/user", accessToken: accessToken, headers: new NameValueCollection { { "Accept", "application/vnd.github.v3+json" } } ); // help: https://developer.github.com/v3/users/#get-the-authenticated-user // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("login", "UserName", typeof(string)); map.Add("name", "DisplayName"); map.Add("email", "Email"); map.Add("html_url", "Url"); map.Add("avatar_url", "Userpic"); // parse the server response and returns the UserInfo instance return(new UserInfo(result, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo() { // query parameters var parameters = new NameValueCollection { { "oauth_token", this.AccessToken["access_token"].ToString() } }; // execute the request var result = OAuthUtility.ExecuteRequest ( "GET", "https://api.soundcloud.com/me.json", parameters, null ); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("username", "DisplayName"); map.Add("permalink_url", "Url"); // website map.Add("avatar_url", "Userpic"); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); // parse the server response and returns the UserInfo instance return(new UserInfo(result.Result as Dictionary <string, object>, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo() { // query parameters var parameters = new NameValueCollection { { "access_token", this.AccessToken["access_token"].ToString() } }; // execute the request var result = OAuthUtility.ExecuteRequest ( "GET", "https://api.dropbox.com/1/account/info", parameters, null ); // field mapping var map = new ApiDataMapping(); map.Add("uid", "UserId", typeof(string)); map.Add("display_name", "DisplayName"); map.Add("email", "Email"); // parse the server response and returns the UserInfo instance return(new UserInfo(result.Result as Dictionary <string, object>, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // query parameters var parameters = new NameValueCollection { { "oauth_token", accessToken.Value } }; // execute the request var result = OAuthUtility.Get("https://api.soundcloud.com/me.json", parameters); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("username", "DisplayName"); map.Add("permalink_url", "Url"); // website map.Add("avatar_url", "Userpic"); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); // parse the server response and returns the UserInfo instance return(new UserInfo(result, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <remarks> /// <para>Access token must contain the user ID in the parameter <b>xoauth_yahoo_guid</b>.</para> /// </remarks> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); string url = String.Format("https://social.yahooapis.com/v1/user/{0}/profile?format=json", accessToken["xoauth_yahoo_guid"]); var result = OAuthUtility.Get ( endpoint: url, accessToken: accessToken ); var map = new ApiDataMapping(); map.Add("guid", "UserId", typeof(string)); map.Add("givenName", "FirstName"); map.Add("familyName", "LastName"); map.Add("nickname", "DisplayName"); map.Add("profileUrl", "Url"); map.Add("lang", "Language"); map.Add("birthdate", "Birthday", typeof(DateTime), @"MM\/dd\/yyyy"); map.Add ( "gender", "Sex", delegate(UniValue value) { if (!value.HasValue) { return(Sex.None); } if (value.Equals("M", StringComparison.OrdinalIgnoreCase)) { return(Sex.Male); } else if (value.Equals("F", StringComparison.OrdinalIgnoreCase)) { return(Sex.Female); } return(Sex.None); } ); map.Add ( "image", "Userpic", delegate(UniValue value) { return(Convert.ToString(value["imageUrl"])); } ); map.Add ( "phones", "Phone", delegate(UniValue value) { return(Convert.ToString(value["number"])); } ); return(new UserInfo(result["profile"], map)); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Get ( "https://api.assembla.com/v1/user.json", accessToken: accessToken ); // help: http://api-doc.assembla.com/content/ref/user_show.html // http://api-doc.assembla.com/content/ref/user_fields.html // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("login", "UserName", typeof(string)); map.Add("name", "DisplayName"); map.Add("email", "Email"); map.Add("phone", "Phone"); // parse the server response and returns the UserInfo instance return(new UserInfo(result, map)); }
/// <summary> /// Gets an user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { // api documentation: // https://www.tumblr.com/docs/en/api/v2#user-methods accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); this.Authorization["oauth_token"] = accessToken["oauth_token"].ToString(); this.Authorization.TokenSecret = accessToken["oauth_token_secret"].ToString(); // required new stamp this.Authorization.Timestamp = OAuthUtility.GetTimeStamp(); this.Authorization.Nonce = OAuthUtility.GetRandomKey(); // execute the request var result = OAuthUtility.Get ( endpoint: "https://api.tumblr.com/v2/user/info", parameters: new HttpParameterCollection { new HttpUrlParameter("api_key", this.ApplicationId) }, authorization: this.Authorization ); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("name", "DisplayName"); // parse the server response and returns the UserInfo instance return(new UserInfo(result["response"]["user"], map)); }
public string GetTumbNail(string id) { var parameter = new HttpParameterCollection() { { "access_token", driveinfo.token.access_token } }; var result = OAuthUtility.Get(string.Format("https://api.onedrive.com/v1.0/drive/items/{0}/thumbnails", id), parameter); var map = new ApiDataMapping(); map.Add("medium", "Thumnail"); FileInfo fi = null; foreach (var item in result.Result.CollectionItems.Items["value"].CollectionItems.Items.Values) { fi = new FileInfo(item, map); } if (fi != null) { int index = fi.Thumnail.IndexOf("url"); int last = fi.Thumnail.LastIndexOf(","); fi.Thumnail = fi.Thumnail.Substring(index, last - index); fi.Thumnail = fi.Thumnail.Substring(7, (fi.Thumnail.Length - 3) - 5); return(fi.Thumnail); } else { return(null); } }
public CloudFiles AddFiles(Dictionary <string, object> items) { UniValue file = UniValue.Create((Dictionary <string, object>)items); var map = new ApiDataMapping(); map.Add("id", "FileID"); map.Add("name", "FileName"); map.Add("@content.downloadUrl", "DownUrl"); map.Add("size", "FileSize", typeof(long)); map.Add("lastModifiedDateTime", "modifiedDate"); FileInfo fi = new FileInfo(file, map); fi.driveinfo = driveinfo; if (fi.Items.CollectionItems.ContainsKey("folder")) { fi.IsFile = false; } else { fi.IsFile = true; fi.Extention = GetExtension(fi.FileName); } fi.Thumnail = GetTumbNail(fi.FileID); OneDriveFile itemss = new OneDriveFile(fi); files.Add(itemss); return(itemss); }
/// <summary> /// Gets the user details. /// </summary> public override UserInfo GetUserInfo() { string url = String.Format("https://social.yahooapis.com/v1/user/{0}/profile?format=json", this.AccessToken["xoauth_yahoo_guid"]); var result = OAuthUtility.ExecuteRequest ( method: "GET", endpoint: url, authorization: String.Format("Bearer {0}", this.AccessToken["access_token"]) ); var map = new ApiDataMapping(); map.Add("guid", "UserId", typeof(string)); map.Add("givenName", "FirstName"); map.Add("familyName", "LastName"); map.Add("nickname", "DisplayName"); map.Add("profileUrl", "Url"); map.Add("birthdate", "Birthday", typeof(DateTime), @"MM\/dd\/yyyy"); map.Add ( "gender", "Sex", delegate(object value) { if (value == null) { return(Sex.None); } if (value.ToString().Equals("M", StringComparison.OrdinalIgnoreCase)) { return(Sex.Male); } else if (value.ToString().Equals("F", StringComparison.OrdinalIgnoreCase)) { return(Sex.Female); } return(Sex.None); } ); map.Add ( "image", "Userpic", delegate(object value) { return(OAuthUtility.GetDictionaryValueOrNull(value, "imageUrl")); } ); map.Add ( "phones", "Phone", delegate(object value) { return(OAuthUtility.GetDictionaryValueOrNull(value, "number")); } ); return(new UserInfo(result["profile"] as Dictionary <string, object>, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> /// <exception cref="ApiException"/> public override UserInfo GetUserInfo() { // http://api.mail.ru/docs/reference/rest/users.getInfo/ var parameters = new NameValueCollection { { "method", "users.getInfo" }, { "app_id", this.ApplicationId }, { "secure", "1" }, { "uid", this.AccessToken["x_mailru_vid"].ToString() }, { "format", "json" } }; string signatureBaseString = parameters.Sort().ToParametersString(); parameters["sig"] = OAuthUtility.GetMD5Hash(signatureBaseString + this.ApplicationSecret); var result = OAuthUtility.ExecuteRequest ( "POST", "http://www.appsmail.ru/platform/api", parameters ); if (!result.IsArray) { throw new ApiException(result, "Expected one-dimensional array."); //Ожидается одномерный массив. } var map = new ApiDataMapping(); map.Add("uid", "UserId", typeof(string)); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); map.Add("nick", "DisplayName"); map.Add("email", "Email"); map.Add("email", "UserName"); map.Add("pic", "Userpic"); map.Add("link", "Url"); map.Add("birthday", "Birthday", typeof(DateTime), @"dd\.MM\.yyyy"); map.Add ( "sex", "Sex", delegate(object value) { if (Convert.ToInt32(value) == 0) { return(Sex.Male); } else if (Convert.ToInt32(value) == 1) { return(Sex.Female); } return(Sex.None); } ); return(new UserInfo(result[0] as Dictionary <string, object>, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // query parameters var parameters = new NameValueCollection { { "format", "json" }, { "oauth_token", accessToken.Value }, }; // execute the request var result = OAuthUtility.Get("https://login.yandex.ru/info", parameters); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("login", "UserName"); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); map.Add("display_name", "DisplayName"); map.Add("birthday", "Birthday", typeof(DateTime), @"yyyy\-MM\-dd"); map.Add("default_email", "Email"); /*map.Add * ( * "emails", "Email", * delegate(object value) * { * if (value != null && value.GetType().IsArray) * { * return ((Array)value).GetValue(0); * } * return null; * } * );*/ map.Add ( "sex", "Sex", delegate(UniValue value) { if (value.Equals("male", StringComparison.OrdinalIgnoreCase)) { return(Sex.Male); } else if (value.Equals("female", StringComparison.OrdinalIgnoreCase)) { return(Sex.Female); } return(Sex.None); } ); // parse the server response and returns the UserInfo instance return(new UserInfo(result, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> /// <remarks> /// <para>For more information, please visit to <see href="https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account"/>.</para> /// </remarks> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Post("https://api.dropboxapi.com/2/users/get_current_account", accessToken: accessToken); // field mapping var map = new ApiDataMapping(); map.Add("account_id", "UserId", typeof(string)); map.Add("email", "Email"); map.Add("profile_photo_url", "Userpic"); map.Add("locale", "Language"); map.Add ( "name", "DisplayName", delegate(UniValue value) { if (!value.HasValue) { return(null); } return(value["display_name"].ToString()); } ); map.Add ( "name", "FirstName", delegate(UniValue value) { if (!value.HasValue) { return(null); } return(value["given_name"].ToString()); } ); map.Add ( "name", "LastName", delegate(UniValue value) { if (!value.HasValue) { return(null); } return(value["surname"].ToString()); } ); // parse the server response and returns the UserInfo instance return(new UserInfo(result, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <remarks> /// <para> /// For more details, please see <see href="https://developers.facebook.com/docs/graph-api/reference/v2.7/user">User</see> method in <b>Guide of Facebook Graph API</b>. /// </para> /// </remarks> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Get("https://graph.facebook.com/v2.7/me?fields=id,name,first_name,last_name,email,birthday,link,gender,languages", accessToken: accessToken); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); map.Add("name", "DisplayName"); map.Add("email", "Email"); map.Add("link", "Url"); // website map.Add("birthday", "Birthday", typeof(DateTime), @"MM\/dd\/yyyy"); map.Add ( "gender", "Sex", delegate(UniValue value) { if (value.HasValue) { if (value.Equals("male", StringComparison.OrdinalIgnoreCase)) { return(Sex.Male); } else if (value.Equals("female", StringComparison.OrdinalIgnoreCase)) { return(Sex.Female); } } return(Sex.None); } ); map.Add ( "languages", "Language", delegate(UniValue value) { if (value.HasValue && value.Count > 0) { return(value[0]["name"].ToString()); } return(null); } ); // parse the server response and returns the UserInfo instance return(new UserInfo(result, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo() { // query parameters var parameters = new NameValueCollection { { "access_token", this.AccessToken["access_token"].ToString() } }; // execute the request var result = OAuthUtility.ExecuteRequest ( "GET", "https://www.googleapis.com/oauth2/v1/userinfo?alt=json", parameters, null ); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("given_name", "FirstName"); map.Add("family_name", "LastName"); map.Add("name", "DisplayName"); map.Add("email", "Email"); map.Add("link", "Url"); map.Add("picture", "Userpic"); map.Add("birthday", "Birthday", typeof(DateTime), @"MM\/dd\/yyyy"); map.Add ( "gender", "Sex", delegate(object value) { if (value != null) { if (value.ToString().Equals("male", StringComparison.OrdinalIgnoreCase)) { return(Sex.Male); } else if (value.ToString().Equals("female", StringComparison.OrdinalIgnoreCase)) { return(Sex.Female); } } return(Sex.None); } ); // parse the server response and returns the UserInfo instance return(new UserInfo(result.Result as Dictionary <string, object>, map)); }
public async Task AddFiles(string id) { try { RequestResult result = OAuthUtility.Get("https://api.dropbox.com/1/metadata/auto/", new HttpParameterCollection { { "path", id }, { "access_token", driveinfo.token.access_token }, { "include_media_info", "true" } }); var map = new ApiDataMapping(); map.Add("path", "FileID"); map.Add("path", "FileName"); map.Add("thumb_exists", "Thumnail"); map.Add("bytes", "FileSize", typeof(long)); map.Add("modified", "modifiedDate"); foreach (var item in result.CollectionItems.Items["contents"].CollectionItems.Items.Values) { FileInfo fi = new FileInfo(item, map); fi.driveinfo = driveinfo; if (id == "/") { fi.Path = "DropBox/"; } if (fi.Thumnail == "True") { fi.Thumnail = GetTumbNail(true, fi.FileID); } else { fi.Thumnail = GetTumbNail(false, fi.FileID); } if (item["icon"].ToString() == "folder" || item["icon"].ToString() == "folder_app") { fi.IsFile = false; fi.Path += fi.FileID; } else { fi.IsFile = true; fi.FileName = GetFileName(fi.FileName); fi.Extention = GetExtension(fi.FileName); } fi.DownUrl = "https://api-content.dropbox.com/1/files/auto/" + fi.FileID; DropBoxFile items = new DropBoxFile(fi); file.Add(items); } } catch (Exception e) { MessageBox.Show(string.Format("드롭박스 파일 불러오기 오류 : {0}", e)); } }
public async Task AddFiles(string id) { try { GoogleFiles.Clear(); string query = "'" + id + "' in parents"; var parameter = new HttpParameterCollection { { "q", query }, { "access_token", driveinfo.token.access_token } }; var result = OAuthUtility.Get("https://www.googleapis.com/drive/v2/files", parameter); var map = new ApiDataMapping(); map.Add("id", "FileID"); map.Add("title", "FileName"); map.Add("fileExtension", "Extention"); map.Add("downloadUrl", "DownUrl"); map.Add("thumbnailLink", "Thumnail"); map.Add("fileSize", "FileSize", typeof(long)); map.Add("description", "Description"); map.Add("modifiedDate", "modifiedDate"); foreach (var item in result.CollectionItems.Items["items"].CollectionItems.Items.Values) { FileInfo fi = new FileInfo(item, map); fi.driveinfo = driveinfo; if (id == "root") { fi.Path = "Google/"; } if (fi.Extention != null) { fi.DownUrl = "https://www.googleapis.com/drive/v2/files/" + fi.FileID + "?alt=media"; fi.IsFile = true; } else { fi.Path += fi.FileName + "/"; fi.IsFile = false; } GoogleFile itemss = new GoogleFile(fi); GoogleFiles.Add(itemss); } } catch (Exception e) { MessageBox.Show(string.Format("구글 파일 불러오기 오류 : {0}", e)); } }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Get("https://api.amazon.com/user/profile", accessToken: accessToken); // field mapping var map = new ApiDataMapping(); map.Add("user_id", "UserId"); map.Add("name", "DisplayName"); map.Add("email", "Email"); // parse the server response and returns user info return(new UserInfo(result, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Get ( "https://www.googleapis.com/oauth2/v3/userinfo", accessToken: accessToken ); // field mapping var map = new ApiDataMapping(); map.Add("sub", "UserId", typeof(string)); map.Add("given_name", "FirstName"); map.Add("family_name", "LastName"); map.Add("name", "DisplayName"); map.Add("email", "Email"); map.Add("link", "Url"); map.Add("picture", "Userpic"); map.Add("locale", "Language"); map.Add("birthday", "Birthday", typeof(DateTime), @"MM\/dd\/yyyy"); map.Add ( "gender", "Sex", delegate(UniValue value) { if (value.Equals("male", StringComparison.OrdinalIgnoreCase)) { return(Sex.Male); } else if (value.Equals("female", StringComparison.OrdinalIgnoreCase)) { return(Sex.Female); } else { return(Sex.None); } } ); // parse the server response and returns the UserInfo instance return(new UserInfo(result, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <remarks> /// <para> /// For more details, please see <see href="https://developers.facebook.com/docs/graph-api/reference/v2.0/user">User</see> method in <b>Guide of Facebook Graph API</b>. /// </para> /// </remarks> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // query parameters var parameters = new NameValueCollection { { "access_token", this.AccessToken["access_token"].ToString() } }; // execute the request var result = OAuthUtility.Get("https://graph.facebook.com/me", parameters); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); map.Add("name", "DisplayName"); map.Add("email", "Email"); map.Add("link", "Url"); // website map.Add("birthday", "Birthday", typeof(DateTime), @"MM\/dd\/yyyy"); map.Add ( "gender", "Sex", delegate(UniValue value) { if (value.HasValue) { if (value.Equals("male", StringComparison.OrdinalIgnoreCase)) { return(Sex.Male); } else if (value.Equals("female", StringComparison.OrdinalIgnoreCase)) { return(Sex.Female); } } return(Sex.None); } ); // parse the server response and returns the UserInfo instance return(new UserInfo(result, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Get("https://api.dropbox.com/1/account/info", accessToken: accessToken); // field mapping var map = new ApiDataMapping(); map.Add("uid", "UserId", typeof(string)); map.Add("display_name", "DisplayName"); map.Add("email", "Email"); // parse the server response and returns the UserInfo instance return(new UserInfo(result, map)); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <param name="usersname">Name of the user whose data should be obtained.</param> public UserInfo GetUserInfo(AccessToken accessToken = null, string usersname = "") { if (String.IsNullOrEmpty("usersname")) { throw new ArgumentNullException("usersname"); } // help: https://sourceforge.net/p/forge/documentation/Allura%20API/#user string url = String.Format("https://sourceforge.net/rest/u/{0}/profile", usersname); this.Authorization["oauth_token"] = this.AccessToken["oauth_token"]; this.Authorization.TokenSecret = this.AccessToken["oauth_token_secret"].ToString(); base.Authorization["oauth_body_hash"] = "2jmj7l5rSw0yVb/vlWAYkK/YBwk="; base.Authorization.Build("GET", url, null, null); // execute the request var result = OAuthUtility.Get(url, base.Authorization.Value.ToNameValueCollection()); // field mapping var map = new ApiDataMapping(); map.Add("username", "UserName"); map.Add("name", "DisplayName"); map.Add ( "sex", "Sex", delegate(UniValue value) { if (value.Equals("Male", StringComparison.OrdinalIgnoreCase)) { return(Sex.Male); } else if (value.Equals("Female", StringComparison.OrdinalIgnoreCase)) { return(Sex.Female); } return(Sex.None); } ); // parse the server response and returns the UserInfo instance return(new UserInfo(UniValue.Empty, map)); }
public async Task AddFiles(string id) { try { var parameter = new HttpParameterCollection() { { "access_token", driveinfo.token.access_token } }; var result = OAuthUtility.Get(string.Format("https://api.onedrive.com/v1.0/drive/items/{0}/children", id), parameter); var map = new ApiDataMapping(); map.Add("id", "FileID"); map.Add("name", "FileName"); map.Add("@content.downloadUrl", "DownUrl"); map.Add("size", "FileSize", typeof(long)); map.Add("lastModifiedDateTime", "modifiedDate"); foreach (var item in result.Result.CollectionItems.Items["value"].CollectionItems.Items.Values) { FileInfo fi = new FileInfo(item, map); fi.driveinfo = driveinfo; if (id == "root") { fi.Path = "OneDrive/"; } if (fi.Items.CollectionItems.ContainsKey("folder")) { fi.IsFile = false; fi.Path += fi.FileName + "/"; } else { fi.IsFile = true; fi.Extention = GetExtension(fi.FileName); fi.DownUrl = item.CollectionItems["@content.downloadUrl"].ToString(); } fi.Thumnail = GetTumbNail(fi.FileID); OneDriveFile items = new OneDriveFile(fi); files.Add(items); } } catch (Exception e) { MessageBox.Show(string.Format("원드라이브 파일 불러오기 오류 : {0}", e)); } }
/// <summary> /// Gets the user details. /// </summary> public override UserInfo GetUserInfo() { // help: https://dev.twitter.com/docs/api/1/get/users/show string url = "https://api.twitter.com/1.1/users/show.json"; // query parameters var parameters = new NameValueCollection { { "user_id", this.AccessToken["user_id"].ToString() }, { "screen_name", this.AccessToken["screen_name"].ToString() }, { "include_entities", "false" } }; this.Authorization["oauth_token"] = this.AccessToken["oauth_token"]; this.Authorization.SetSignature("GET", new Uri(url), this.ApplicationSecret, this.AccessToken["oauth_token_secret"].ToString(), parameters); //this.Authorization["oauth_signature"] = this.GetSignature("GET", new Uri(url), this.AccessToken["oauth_token_secret"].ToString(), parameters); // execute the request var result = OAuthUtility.ExecuteRequest ( "GET", url, parameters, this.Authorization.ToString() ); // field mapping var map = new ApiDataMapping(); map.Add("id_str", "UserId", typeof(string)); map.Add("name", "DisplayName"); map.Add("screen_name", "UserName"); map.Add("profile_image_url", "Userpic"); map.Add("url", "Url"); map.Add("birthday", "Birthday", typeof(DateTime), @"dd\.MM\.yyyy"); //map.Add("verified", "Url"); //map.Add("location", "Url"); // parse the server response and returns the UserInfo instance return(new UserInfo(result.Result as Dictionary <string, object>, map)); }
private async void button3_Click(object sender, EventArgs e) { if (textBox1.Text != null) { Authentication.DropBoxLogin.TokenResult token = await Authentication.DropBoxLogin.SignInToDropBox(textBox1.Text, @"C:\Test"); var parameter = new NameValueCollection { {"access_token", token.AccessToken} }; var result = OAuthUtility.ExecuteRequest("GET", "https://api.dropbox.com/1/account/info", parameter, null); var map = new ApiDataMapping(); map.Add("uid", "UserId", typeof(string)); map.Add("display_name", "DisplayName"); map.Add("email", "Email"); UserInfo user = new UserInfo((Dictionary<string, object>)result.Result, map); listBox1.Items.Add("DropBox - " + user.DisplayName); dropbox.Add(token); } }
private async void button3_Click(object sender, EventArgs e) { if (textBox1.Text != null) { Authentication.DropBoxLogin.TokenResult token = await Authentication.DropBoxLogin.SignInToDropBox(textBox1.Text, @"C:\Test"); var parameter = new NameValueCollection { { "access_token", token.AccessToken } }; var result = OAuthUtility.ExecuteRequest("GET", "https://api.dropbox.com/1/account/info", parameter, null); var map = new ApiDataMapping(); map.Add("uid", "UserId", typeof(string)); map.Add("display_name", "DisplayName"); map.Add("email", "Email"); UserInfo user = new UserInfo((Dictionary <string, object>)result.Result, map); listBox1.Items.Add("DropBox - " + user.DisplayName); dropbox.Add(token); } }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> public override UserInfo GetUserInfo(AccessToken accessToken = null) { // help: https://dev.twitter.com/docs/api/1/get/users/show accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); string url = "https://api.twitter.com/1.1/users/show.json"; // query parameters var parameters = new HttpParameterCollection(); parameters.AddUrlParameter("user_id", accessToken["user_id"].ToString()); parameters.AddUrlParameter("screen_name", accessToken["screen_name"].ToString()); parameters.AddUrlParameter("include_entities", "false"); this.Authorization["oauth_token"] = accessToken["oauth_token"].ToString(); this.Authorization.TokenSecret = accessToken["oauth_token_secret"].ToString(); // execute the request var result = OAuthUtility.Get(url, parameters, this.Authorization); // field mapping var map = new ApiDataMapping(); map.Add("id_str", "UserId", typeof(string)); map.Add("name", "DisplayName"); map.Add("screen_name", "UserName"); map.Add("profile_image_url", "Userpic"); map.Add("url", "Url"); map.Add("birthday", "Birthday", typeof(DateTime), @"dd\.MM\.yyyy"); //map.Add("verified", "Url"); //map.Add("location", "Url"); // parse the server response and returns the UserInfo instance return new UserInfo(result, map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { // https://developer.foursquare.com/docs/users/users accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // query parameters var parameters = new NameValueCollection { { "oauth_token", accessToken.Value }, { "v", "20141025" } }; // execute the request var result = OAuthUtility.Get("https://api.foursquare.com/v2/users/self", parameters); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("firstName", "FirstName"); map.Add("lastName", "LastName"); map.Add ( "photo", "Userpic", delegate(UniValue value) { if (!value.HasValue || !value.ContainsKey("prefix") || !value.ContainsKey("suffix")) { return null; } return String.Format("{0}300x300{1}", value["prefix"], value["suffix"]); } ); map.Add ( "contact", "Email", delegate(UniValue value) { return value["email"].ToString(); } ); map.Add ( "contact", "Phone", delegate(UniValue value) { return value["phone"].ToString(); } ); map.Add ( "gender", "Sex", delegate(UniValue value) { if (value.Equals("male", StringComparison.OrdinalIgnoreCase)) { return Sex.Male; } else if (value.Equals("female", StringComparison.OrdinalIgnoreCase)) { return Sex.Female; } return Sex.None; } ); // parse the server response and returns the UserInfo instance return new UserInfo(result["response"]["user"], map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Get("https://api.github.com/user", accessToken: accessToken); // help: https://developer.github.com/v3/users/#get-the-authenticated-user // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("login", "UserName", typeof(string)); map.Add("name", "DisplayName"); map.Add("email", "Email"); map.Add("html_url", "Url"); map.Add("avatar_url", "Userpic"); // parse the server response and returns the UserInfo instance return new UserInfo(result, map); }
public UserInfo(Dictionary<string, object> source, ApiDataMapping mapping) : this(new UniValue(source), mapping) { }
/// <summary> /// Gets an user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { // api documentation: // https://www.tumblr.com/docs/en/api/v2#user-methods accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); this.Authorization["oauth_token"] = accessToken["oauth_token"].ToString(); this.Authorization.TokenSecret = accessToken["oauth_token_secret"].ToString(); // required new stamp this.Authorization.Timestamp = OAuthUtility.GetTimeStamp(); this.Authorization.Nonce = OAuthUtility.GetRandomKey(); // execute the request var result = OAuthUtility.Get ( endpoint: "https://api.tumblr.com/v2/user/info", parameters: new HttpParameterCollection { new HttpUrlParameter("api_key", this.ApplicationId) }, authorization: this.Authorization ); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("name", "DisplayName"); // parse the server response and returns the UserInfo instance return new UserInfo(result["response"]["user"], map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <exception cref="ApiException"/> public override UserInfo GetUserInfo(AccessToken accessToken = null) { // http://apiok.ru/wiki/pages/viewpage.action?pageId=46137373#APIДокументация(Русский)-users.getCurrentUser accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // query parameters var parameters = new NameValueCollection { { "method", "users.getCurrentUser" }, { "application_key", this.ApplicationKey }, { "format", "json" }, { "fields", "uid,first_name,last_name,name,gender,birthday,location,pic640x480,email" } }; // signature base string // http://apiok.ru/wiki/pages/viewpage.action?pageId=75989046 string signatureBaseString = parameters.Sort().ToParametersString(true); signatureBaseString += OAuthUtility.GetMD5Hash(accessToken.Value + this.ApplicationSecret); // calculate the signature parameters["sig"] = OAuthUtility.GetMD5Hash(signatureBaseString); parameters["access_token"] = accessToken.Value; // execute the request var result = OAuthUtility.Post("http://api.odnoklassniki.ru/fb.do", parameters); // error result if (result["error_code"].HasValue) { throw new ApiException ( result, result.ContainsKey("error_msg") ? result["error_msg"].ToString() : null ); } // successfully // field mapping var map = new ApiDataMapping(); map.Add("uid", "UserId", typeof(string)); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); map.Add("name", "DisplayName"); map.Add("email", "Email"); map.Add("email", "UserName"); map.Add("pic640x480", "Userpic"); map.Add("link", "Url"); map.Add("birthday", "Birthday", typeof(DateTime), @"yyyy\-MM\-dd"); map.Add ( "gender", "Sex", delegate(UniValue value) { if (value.Equals("male", StringComparison.OrdinalIgnoreCase)) { return Sex.Male; } else if (value.Equals("female", StringComparison.OrdinalIgnoreCase)) { return Sex.Female; } return Sex.None; } ); return new UserInfo(result, map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> /// <remarks> /// <para>The access token must contain the user ID in the parameter <b>x_mailru_vid</b>.</para> /// </remarks> /// <exception cref="ApiException"/> public override UserInfo GetUserInfo(AccessToken accessToken = null) { // http://api.mail.ru/docs/reference/rest/users.getInfo/ accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); var parameters = new NameValueCollection { { "method", "users.getInfo" }, { "app_id", this.ApplicationId }, { "secure", "1" }, { "uid", accessToken["x_mailru_vid"].ToString() }, { "format", "json" } }; string signatureBaseString = parameters.Sort().ToParametersString(); parameters["sig"] = OAuthUtility.GetMD5Hash(signatureBaseString + this.ApplicationSecret); var result = OAuthUtility.Post("http://www.appsmail.ru/platform/api", parameters); if (!result.IsCollection) { throw new ApiException(result, "Expected one-dimensional array."); // expected one-dimensional array. } var map = new ApiDataMapping(); map.Add("uid", "UserId", typeof(string)); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); map.Add("nick", "DisplayName"); map.Add("email", "Email"); map.Add("email", "UserName"); map.Add("pic", "Userpic"); map.Add("link", "Url"); map.Add("birthday", "Birthday", typeof(DateTime), @"dd\.MM\.yyyy"); map.Add ( "sex", "Sex", delegate(UniValue value) { if (Convert.ToInt32(value) == 0) { return Sex.Male; } else if (Convert.ToInt32(value) == 1) { return Sex.Female; } return Sex.None; } ); return new UserInfo(result.First(), map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); var result = OAuthUtility.Get ( "https://api.instagram.com/v1/users/self", accessToken: accessToken ); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("username", "UserName"); map.Add("website", "Url"); map.Add("profile_picture", "Userpic"); map.Add("full_name", "DisplayName"); // parse the server response and returns the UserInfo instance return new UserInfo(result["data"], map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { // http://msdn.microsoft.com/en-us/library/hh243648.aspx accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); var result = OAuthUtility.Get ( "https://apis.live.net/v5.0/me", accessToken: accessToken ); var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); map.Add("name", "DisplayName"); map.Add("link", "Url"); map.Add ( "birth_day", "Birthday", delegate(UniValue value) { if (!value.HasValue) { return null; } return new DateTime ( Convert.ToInt32(result["birth_year"]), Convert.ToInt32(result["birth_month"]), Convert.ToInt32(result["birth_day"]) ); } ); map.Add ( "emails", "Email", delegate(UniValue value) { return Convert.ToString(value["preferred"]); } ); map.Add ( "phones", "Phone", delegate(UniValue value) { return Convert.ToString(value["mobile"]); } ); map.Add ( "gender", "Sex", delegate(UniValue value) { if (value.Equals("male", StringComparison.OrdinalIgnoreCase)) { return Sex.Male; } else if (value.Equals("female", StringComparison.OrdinalIgnoreCase)) { return Sex.Female; } else { return Sex.None; } } ); return new UserInfo(result, map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Get("https://api.amazon.com/user/profile", accessToken: accessToken); // field mapping var map = new ApiDataMapping(); map.Add("user_id", "UserId"); map.Add("name", "DisplayName"); map.Add("email", "Email"); // parse the server response and returns user info return new UserInfo(result, map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <exception cref="ApiException"/> public override UserInfo GetUserInfo(AccessToken accessToken = null) { // help: http://vk.com/dev/users.get accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // query parameters var parameters = new NameValueCollection { { "user_ids", accessToken["user_id"].ToString() }, { "fields", "sex,bdate,city,country,photo_max_orig,domain,contacts,site" } }; // execute the request var result = OAuthUtility.Get ( "https://api.vk.com/method/users.get", parameters: parameters, accessToken: accessToken ); if (result.ContainsKey("error")) { throw new ApiException(result, result["error"]["error_msg"].ToString()); } // field mapping var map = new ApiDataMapping(); map.Add("uid", "UserId", typeof(string)); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); map.Add("domain", "UserName"); map.Add("photo_max_orig", "Userpic"); map.Add("mobile_phone", "Phone"); map.Add("bdate", "Birthday", typeof(DateTime), @"dd\.MM\.yyyy"); map.Add ( "site", "Url", delegate(UniValue value) { if (value.HasValue || String.IsNullOrEmpty(value.ToString())) { return null; } return value.ToString().Split(' ').First(); } ); map.Add ( "sex", "Sex", delegate(UniValue value) { if (Convert.ToInt32(value) == 2) { return Sex.Male; } else if (Convert.ToInt32(value) == 1) { return Sex.Female; } return Sex.None; } ); // email, thanks to Aleksander (KamAz) Kryatov (http://vk.com/acid_rock) for idea if (accessToken.ContainsKey("email")) { result["response"].First().Add("at_email", accessToken["email"]); map.Add("at_email", "Email", typeof(string)); } // -- // parse the server response and returns the UserInfo instance return new UserInfo(result["response"].First(), map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <param name="usersname">Name of the user whose data should be obtained.</param> public UserInfo GetUserInfo(AccessToken accessToken = null, string usersname = "") { if (String.IsNullOrEmpty("usersname")) { throw new ArgumentNullException("usersname"); } // help: https://sourceforge.net/p/forge/documentation/Allura%20API/#user string url = String.Format("https://sourceforge.net/rest/u/{0}/profile", usersname); this.Authorization["oauth_token"] = this.AccessToken["oauth_token"]; this.Authorization.TokenSecret = this.AccessToken["oauth_token_secret"].ToString(); base.Authorization["oauth_body_hash"] = "2jmj7l5rSw0yVb/vlWAYkK/YBwk="; base.Authorization.Build("GET", url, null, null); // execute the request var result = OAuthUtility.Get(url, base.Authorization.Value.ToNameValueCollection()); // field mapping var map = new ApiDataMapping(); map.Add("username", "UserName"); map.Add("name", "DisplayName"); map.Add ( "sex", "Sex", delegate(UniValue value) { if (value.Equals("Male", StringComparison.OrdinalIgnoreCase)) { return Sex.Male; } else if (value.Equals("Female", StringComparison.OrdinalIgnoreCase)) { return Sex.Female; } return Sex.None; } ); // parse the server response and returns the UserInfo instance return new UserInfo(UniValue.Empty, map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <remarks> /// <para>Access token must contain the user ID in the parameter <b>xoauth_yahoo_guid</b>.</para> /// </remarks> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); string url = String.Format("https://social.yahooapis.com/v1/user/{0}/profile?format=json", accessToken["xoauth_yahoo_guid"]); var result = OAuthUtility.Get ( endpoint: url, accessToken: accessToken ); var map = new ApiDataMapping(); map.Add("guid", "UserId", typeof(string)); map.Add("givenName", "FirstName"); map.Add("familyName", "LastName"); map.Add("nickname", "DisplayName"); map.Add("profileUrl", "Url"); map.Add("birthdate", "Birthday", typeof(DateTime), @"MM\/dd\/yyyy"); map.Add ( "gender", "Sex", delegate(UniValue value) { if (!value.HasValue) { return Sex.None; } if (value.Equals("M", StringComparison.OrdinalIgnoreCase)) { return Sex.Male; } else if (value.Equals("F", StringComparison.OrdinalIgnoreCase)) { return Sex.Female; } return Sex.None; } ); map.Add ( "image", "Userpic", delegate(UniValue value) { return Convert.ToString(value["imageUrl"]); } ); map.Add ( "phones", "Phone", delegate(UniValue value) { return Convert.ToString(value["number"]); } ); return new UserInfo(result["profile"], map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <remarks> /// <para> /// For more details, please see <see href="https://developers.facebook.com/docs/graph-api/reference/v2.0/user">User</see> method in <b>Guide of Facebook Graph API</b>. /// </para> /// </remarks> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // query parameters var parameters = new NameValueCollection { { "access_token" , this.AccessToken["access_token"].ToString() } }; // execute the request var result = OAuthUtility.Get("https://graph.facebook.com/me", parameters); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); map.Add("name", "DisplayName"); map.Add("email", "Email"); map.Add("link", "Url"); // website map.Add("birthday", "Birthday", typeof(DateTime), @"MM\/dd\/yyyy"); map.Add ( "gender", "Sex", delegate(UniValue value) { if (value.HasValue) { if (value.Equals("male", StringComparison.OrdinalIgnoreCase)) { return Sex.Male; } else if (value.Equals("female", StringComparison.OrdinalIgnoreCase)) { return Sex.Female; } } return Sex.None; } ); // parse the server response and returns the UserInfo instance return new UserInfo(result, map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Get("https://api.dropbox.com/1/account/info", accessToken: accessToken); // field mapping var map = new ApiDataMapping(); map.Add("uid", "UserId", typeof(string)); map.Add("display_name", "DisplayName"); map.Add("email", "Email"); // parse the server response and returns the UserInfo instance return new UserInfo(result, map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Get ( "https://api.codeproject.com/v1/my/profile", accessToken: accessToken ); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("userName", "UserName", typeof(string)); map.Add("displayName", "DisplayName"); map.Add("email", "Email"); map.Add("homePage", "Url"); map.Add("avatar", "Userpic"); // parse the server response and returns the UserInfo instance return new UserInfo(result, map); }
/// <summary> /// Initializes a new instance of the <see cref="UserInfo"/> class. /// </summary> /// <param name="source">The data source.</param> /// <param name="mapping">The mapping rules.</param> public UserInfo(UniValue source, ApiDataMapping mapping) { if (mapping == null || !source.HasValue) { return; } this.Items = source; var t = typeof(UserInfo); foreach (var p in t.GetProperties()) { var item = mapping.FirstOrDefault(itm => itm.DestinationName.Equals(p.Name, StringComparison.OrdinalIgnoreCase)); if (item != null && source.ContainsKey(item.SourceName)) { object vr = null; UniValue vs = source[item.SourceName]; if (item.Parse != null) { vr = item.Parse(vs); } else { if (item.Type == typeof(DateTime)) { var f = new CultureInfo(Thread.CurrentThread.CurrentCulture.Name, true); var formatDateTime = "dd.MM.yyyy HH:mm:ss"; if (!String.IsNullOrEmpty(item.Format)) { formatDateTime = item.Format; } f.DateTimeFormat.FullDateTimePattern = formatDateTime; f.DateTimeFormat.ShortDatePattern = formatDateTime; DateTime dateValue; if (DateTime.TryParse(vs.ToString(), f, DateTimeStyles.NoCurrentDateDefault, out dateValue)) { vr = dateValue; } else { vr = null; } } else if (item.Type == typeof(bool)) { vr = Convert.ToBoolean(vs); } else if (item.Type == typeof(Int16)) { vr = Convert.ToInt16(vs); } else if (item.Type == typeof(Int32)) { vr = Convert.ToInt32(vs); } else if (item.Type == typeof(Int64)) { vr = Convert.ToInt64(vs); } else if (item.Type == typeof(UInt16)) { vr = Convert.ToUInt16(vs); } else if (item.Type == typeof(UInt32)) { vr = Convert.ToUInt32(vs); } else if (item.Type == typeof(UInt64)) { vr = Convert.ToUInt64(vs); } else if (item.Type == typeof(double)) { vr = Convert.ToDouble(vs); } else if (item.Type == typeof(Single)) { vr = Convert.ToSingle(vs); } else if (item.Type == typeof(decimal)) { vr = Convert.ToDecimal(vs); } else if (item.Type == typeof(byte)) { vr = Convert.ToByte(vs); } else if (item.Type == typeof(char)) { vr = Convert.ToChar(vs); } else if (item.Type == typeof(string)) { vr = Convert.ToString(vs); } else { vr = Convert.ToString(vs); } } p.SetValue(this, vr, null); } } }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // execute the request var result = OAuthUtility.Get ( "https://api.assembla.com/v1/user.json", accessToken: accessToken ); // help: http://api-doc.assembla.com/content/ref/user_show.html // http://api-doc.assembla.com/content/ref/user_fields.html // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("login", "UserName", typeof(string)); map.Add("name", "DisplayName"); map.Add("email", "Email"); map.Add("phone", "Phone"); // parse the server response and returns the UserInfo instance return new UserInfo(result, map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // query parameters var parameters = new NameValueCollection { { "oauth_token", accessToken.Value } }; // execute the request var result = OAuthUtility.Get("https://api.soundcloud.com/me.json", parameters); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("username", "DisplayName"); map.Add("permalink_url", "Url"); // website map.Add("avatar_url", "Userpic"); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); // parse the server response and returns the UserInfo instance return new UserInfo(result, map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> public override UserInfo GetUserInfo(AccessToken accessToken = null) { accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // query parameters var parameters = new NameValueCollection { { "format", "json" }, { "oauth_token", accessToken.Value }, }; // execute the request var result = OAuthUtility.Get("https://login.yandex.ru/info", parameters); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("login", "UserName"); map.Add("first_name", "FirstName"); map.Add("last_name", "LastName"); map.Add("display_name", "DisplayName"); map.Add("birthday", "Birthday", typeof(DateTime), @"yyyy\-MM\-dd"); map.Add("default_email", "Email"); /*map.Add ( "emails", "Email", delegate(object value) { if (value != null && value.GetType().IsArray) { return ((Array)value).GetValue(0); } return null; } );*/ map.Add ( "sex", "Sex", delegate(UniValue value) { if (value.Equals("male", StringComparison.OrdinalIgnoreCase)) { return Sex.Male; } else if (value.Equals("female", StringComparison.OrdinalIgnoreCase)) { return Sex.Female; } return Sex.None; } ); // parse the server response and returns the UserInfo instance return new UserInfo(result, map); }
/// <summary> /// Gets the user details. /// </summary> /// <param name="accessToken">May contain an access token, which will have to be used in obtaining information about the user.</param> /// <returns> /// <para>Returns an instance of the <see cref="UserInfo"/> class, containing information about the user.</para> /// </returns> public override UserInfo GetUserInfo(AccessToken accessToken = null) { // api documentation: // https://developer.linkedin.com/apis // https://developer.linkedin.com/documents/profile-api // https://developer.linkedin.com/documents/profile-fields accessToken = base.GetSpecifiedTokenOrCurrent(accessToken); // fix: server does not return token type, but requires Bearer accessToken = new OAuth2AccessToken ( accessToken.Value, ((OAuth2AccessToken)accessToken).RefreshToken, AccessTokenType.Bearer ); // execute the request var result = OAuthUtility.Get ( endpoint: "https://api.linkedin.com/v1/people/~:(id,first-name,last-name,picture-url,email-address)", accessToken: accessToken, headers: new NameValueCollection { { "x-li-format", "json" } } ); // field mapping var map = new ApiDataMapping(); map.Add("id", "UserId", typeof(string)); map.Add("firstName", "FirstName"); map.Add("lastName", "LastName"); map.Add("pictureUrl", "Userpic"); map.Add("emailAddress", "Email"); // parse the server response and returns the UserInfo instance return new UserInfo(result, map); }