public static bool OpenPublishDialog(OKRequestCallback callback, Action onClosed, OKMedia media) { return(OpenPublishDialog(callback, onClosed, new List <OKMedia>() { media })); }
public static bool OpenPublishDialog(OKRequestCallback callback, OKMedia media) { return(OpenPublishDialog(callback, null, new List <OKMedia>() { media })); }
public bool OpenInviteDialog(OKRequestCallback callback, Action onClosed, string defaultMessage, string[] selected) { Api(OKMethod.Friends.get, response => { ArrayList uids = response.Array; OK.GetAppUsers(appUsers => { foreach (string appUser in appUsers) { uids.Remove(appUser); } string[] fields = { OKUserInfo.Field.pic128x128, OKUserInfo.Field.name }; if (uids.Count > 0) { GetInfo(ToStringArray(uids), fields, false, users => { OKWidgets.OpenInviteDialog(callback, onClosed, users, defaultMessage, selected, this); }); } else { OKWidgets.OpenInviteDialog(callback, onClosed, new OKUserInfo[0], defaultMessage, new string[0], this); } }); }); return(true); }
public void GetFriendsByDevices(OKRequestCallback callback, string[] devices) { Api(OKMethod.Friends.getByDevices, new Dictionary <string, string> { { "devices", string.Join(",", devices) } }, callback ); }
private void Publish(Hashtable attachment, OKRequestCallback callback) { Api(OKMethod.SDK.post, new Dictionary <string, string> { { "attachment", JSON.Encode(attachment) } }, callback ); }
private void AppSuggest(string[] uids, string text, OKRequestCallback callback) { Api(OKMethod.SDK.appSuggest, new Dictionary <string, string> { { "uids", string.Join(",", uids) }, { "text", text } }, callback ); }
private void UploadPhoto(Texture2D texture, string comment, OKRequestCallback callback) { Api("photosV2.getUploadUrl", uploadUrlResponse => { Hashtable obj = uploadUrlResponse.Object; if (obj == null) { Debug.LogError("Bad response: bad format"); return; } if (!obj.ContainsKey("upload_url")) { Debug.LogError("Bad response: no upload_url specified"); return; } if (!obj.ContainsKey("photo_ids")) { Debug.LogError("Bad response: no photo_ids specified"); return; } string uploadUrl = (string)obj["upload_url"]; ArrayList photoIds = (ArrayList)obj["photo_ids"]; WWWForm form = new WWWForm(); form.AddBinaryData("pic1", texture.EncodeToJPG(), "pic2.jpg", "multipart/form-data"); new HTTP.Request(uploadUrl, form).Send(request => { if (photoIds.Count != 1) { Debug.LogError("We have been uploading 1 photo, but received response for " + photoIds.Count); return; } string photoId = (string)photoIds[0]; Hashtable uploadResponse = request.response.Object; Hashtable photos = (Hashtable)uploadResponse["photos"]; Hashtable photoObject = (Hashtable)photos[photoId]; string token = (string)photoObject["token"]; Api("photosV2.commit", new Dictionary <string, string> { { "photo_id", photoId }, { "comment", comment }, { "token", token } }, callback ); }); }); }
private void AppInvite(string[] uids, string[] devices, string text, OKRequestCallback callback) { Api(OKMethod.SDK.appInvite, new Dictionary <string, string> { { "uids", string.Join(",", uids) }, { "devices", string.Join(",", devices) }, { "text", text } }, delegate(HTTP.Response response) { callback(response); } ); }
public bool OpenSuggestDialog(OKRequestCallback callback, Action onClosed, string defaultMessage, string[] selected) { Api(OKMethod.Friends.get, response => { ArrayList uids = response.Array; string[] fields = { OKUserInfo.Field.pic128x128, OKUserInfo.Field.name }; if (uids.Count > 0) { GetInfo(ToStringArray(uids), fields, false, users => { OKWidgets.OpenSuggestDialog(callback, onClosed, users, defaultMessage, selected, AppSuggest); }); } else { OKWidgets.OpenSuggestDialog(callback, onClosed, new OKUserInfo[0], defaultMessage, new string[0], AppSuggest); } }); return(true); }
public static bool OpenPublishDialog(OKRequestCallback callback, Action onClosed, List <OKMedia> media) { return(OdnoklassnikiImpl.OpenPublishDialog(callback, onClosed, media)); }
public static void GetFriendsByDevices(OKRequestCallback callback, string[] devices) { OdnoklassnikiImpl.GetFriendsByDevices(callback, devices); }
public static bool OpenSuggestDialog(OKRequestCallback callback, Action onClosed, string defaultMessage, params string[] selected) { return(OdnoklassnikiImpl.OpenSuggestDialog(callback, onClosed, defaultMessage, selected)); }
public static bool OpenPublishDialog(OKRequestCallback callback, List <OKMedia> media) { return(OpenPublishDialog(callback, null, media)); }
public static void API(string query, Method method, OKRequestCallback callback, bool useSession = true) { API(query, method, new Dictionary <string, string>(), callback, useSession); }
public static void API(string query, OKRequestCallback callback) { API(query, Method.GET, new Dictionary <string, string>(), callback); }
public static bool OpenPublishDialog(OKRequestCallback callback, Action onClosed, OKMedia media) { return OpenPublishDialog(callback, onClosed, new List<OKMedia>() { media }); }
public bool OpenPhotoDialog(OKRequestCallback callback, Action onClosed, Texture2D image, string defaultComment) { OKWidgets.OpenPhotoDialog(callback, onClosed, image, defaultComment, UploadPhoto); return(true); }
public static bool OpenPublishDialog(OKRequestCallback callback, OKMedia media) { return OpenPublishDialog(callback, null, new List<OKMedia>() { media }); }
public static bool OpenPublishDialog(OKRequestCallback callback, List<OKMedia> media) { return OpenPublishDialog(callback, null, media); }
public static bool OpenPhotoDialog(OKRequestCallback callback, Action onClosed, Texture2D image, string defaultComment) { return OdnoklassnikiImpl.OpenPhotoDialog(callback, onClosed, image, defaultComment); }
public static bool OpenInviteDialog(OKRequestCallback callback, string defaultMessage, params string[] selected) { return OdnoklassnikiImpl.OpenInviteDialog(callback, defaultMessage, selected); }
private void UploadPhoto(Texture2D texture, string comment, OKRequestCallback callback) { Api("photosV2.getUploadUrl", uploadUrlResponse => { Hashtable obj = uploadUrlResponse.Object; if (obj == null) { Debug.LogError("Bad response: bad format"); return; } if (!obj.ContainsKey("upload_url")) { Debug.LogError("Bad response: no upload_url specified"); return; } if (!obj.ContainsKey("photo_ids")) { Debug.LogError("Bad response: no photo_ids specified"); return; } string uploadUrl = (string)obj["upload_url"]; ArrayList photoIds = (ArrayList)obj["photo_ids"]; WWWForm form = new WWWForm(); form.AddBinaryData("pic1", texture.EncodeToJPG(), "pic2.jpg", "multipart/form-data"); new HTTP.Request(uploadUrl, form).Send(request => { if (photoIds.Count != 1) { Debug.LogError("We have been uploading 1 photo, but received response for " + photoIds.Count); return; } string photoId = (string)photoIds[0]; Hashtable uploadResponse = request.response.Object; Hashtable photos = (Hashtable)uploadResponse["photos"]; Hashtable photoObject = (Hashtable)photos[photoId]; string token = (string)photoObject["token"]; Api("photosV2.commit", new Dictionary<string, string> { {"photo_id", photoId}, {"comment", comment}, {"token", token} }, callback ); }); }); }
public static bool OpenPublishDialog(OKRequestCallback callback, Action onClosed, List<OKMedia> media) { return OdnoklassnikiImpl.OpenPublishDialog(callback, onClosed, media); }
private void Api(string okMethod, OKRequestCallback callback) { Api(okMethod, new Dictionary<string, string>(), callback); }
public static bool OpenSuggestDialog(OKRequestCallback callback, Action onClosed, string defaultMessage, params string[] selected) { return OdnoklassnikiImpl.OpenSuggestDialog(callback, onClosed, defaultMessage, selected); }
public bool OpenSuggestDialog(OKRequestCallback callback, Action onClosed, string defaultMessage, string[] selected) { Api(OKMethod.Friends.get, response => { ArrayList uids = response.Array; string[] fields = { OKUserInfo.Field.pic128x128, OKUserInfo.Field.name }; if (uids.Count > 0) { GetInfo(ToStringArray(uids), fields, false, users => { OKWidgets.OpenSuggestDialog(callback, onClosed, users, defaultMessage, selected, this); }); } else { OKWidgets.OpenSuggestDialog(callback, onClosed, new OKUserInfo[0], defaultMessage, new string[0], this); } }); return true; }
public static void API(string query, Method method, Dictionary<string, string> args, OKRequestCallback callback, bool useSession = true) { OdnoklassnikiImpl.Api(query, method, args, callback, useSession); }
public static void API(string query, Dictionary <string, string> args, OKRequestCallback callback, bool useSession = true) { API(query, Method.GET, args, callback, useSession); }
public static void API(string query, Method method, OKRequestCallback callback, bool useSession = true) { API(query, method, new Dictionary<string, string>(), callback, useSession); }
public static bool OpenInviteDialog(OKRequestCallback callback, string defaultMessage, params string[] selected) { return(OdnoklassnikiImpl.OpenInviteDialog(callback, defaultMessage, selected)); }
public static void API(string query, Dictionary<string, string> args, OKRequestCallback callback, bool useSession = true) { API(query, Method.GET, args, callback, useSession); }
public bool OpenPublishDialog(OKRequestCallback callback, Action onClosed, List<OKMedia> media) { OKWidgets.OpenPublishDialog(callback, onClosed, media, this, UploadPhotoForPublish); return true; }
public static void API(string query, OKRequestCallback callback) { API(query, Method.GET, new Dictionary<string, string>(), callback); }
public bool OpenPhotoDialog(OKRequestCallback callback, Action onClosed, Texture2D image, string defaultComment) { OKWidgets.OpenPhotoDialog(callback, onClosed, image, defaultComment, UploadPhoto); return true; }
private void Api(string query, HTTP.Method method, HTTP.Format format, Dictionary <string, string> args, OKRequestCallback callback, bool useSession = true) { args.Add(ParamApplicationKey, appKey); args.Add(ParamMethod, query); args.Add(ParamFormat, format.ToString()); args.Add(ParamPlatform, GetPlatform().ToUpper()); // Check if target API requires SdkToken. if (OKMethod.RequiresSdkToken(query)) { args.Add(ParamSdkToken, unitySessionKey); } // Override useSession for some API requests that fail if called within session. if (!OKMethod.RequiresSession(query)) { useSession = false; } string url = useSession ? GetApiUrl(args) : GetApiNoSessionUrl(args); new HTTP.Request(url, method, format).Send(request => { //check for error Hashtable obj = request.response.Object; if (obj != null) { if (obj.ContainsKey("error_code")) { string errorCode = obj["error_code"].ToString(); string errorMsg = obj["error_msg"].ToString(); switch (errorCode) { case "100": if (errorMsg == "PARAM : Missed required parameter: access_token") { Debug.Log("Missing access token - trying to auto refresh session"); RefreshAuth(refreshed => { Debug.Log("REFRESHED: " + refreshed); }); } break; case "102": Debug.Log("Session expired - trying to auto refresh session"); RefreshAuth(refreshed => { Debug.Log("REFRESHED: " + refreshed); }); break; case "103": Debug.Log("Invalid session key - trying to auto refresh session"); RefreshAuth(refreshed => { Debug.Log("REFRESHED: " + refreshed); }); break; default: Debug.LogWarning(query + " failed -> " + request.response.Error); callback(request.response); break; } return; } } if (callback != null) { callback(request.response); } }); }
public static bool OpenPhotoDialog(OKRequestCallback callback, Action onClosed, Texture2D image, string defaultComment) { return(OdnoklassnikiImpl.OpenPhotoDialog(callback, onClosed, image, defaultComment)); }
private void Api(string okMethod, Dictionary <string, string> args, OKRequestCallback callback, bool useSession = true) { Api(okMethod, HTTP.Method.GET, args, callback, useSession); }
public void Api(string query, HTTP.Method method, Dictionary <string, string> args, OKRequestCallback callback, bool useSession = true) { Api(query, method, httpFormat, args, callback, useSession); }
private void Api(string okMethod, Dictionary<string, string> args, OKRequestCallback callback, bool useSession = true) { Api(okMethod, HTTP.Method.GET, args, callback, useSession); }
private void Api(string okMethod, OKRequestCallback callback) { Api(okMethod, new Dictionary <string, string>(), callback); }
public bool OpenPhotoDialog(OKRequestCallback callback, Texture2D image, string defaultComment) { return OpenPhotoDialog(callback, null, image, defaultComment); }
public bool OpenPublishDialog(OKRequestCallback callback, Action onClosed, List <OKMedia> media) { OKWidgets.OpenPublishDialog(callback, onClosed, media, this, UploadPhotoForPublish); return(true); }
private void Api(string query, HTTP.Method method, HTTP.Format format, Dictionary<string, string> args, OKRequestCallback callback, bool useSession = true) { args.Add(ParamApplicationKey, appKey); args.Add(ParamMethod, query); args.Add(ParamFormat, format.ToString()); args.Add(ParamPlatform, GetPlatform().ToUpper()); // Check if target API requires SdkToken. if (OKMethod.RequiresSdkToken(query)) { args.Add(ParamSdkToken, unitySessionKey); } // Override useSession for some API requests that fail if called within session. if (!OKMethod.RequiresSession(query)) { useSession = false; } string url = useSession ? GetApiUrl(args) : GetApiNoSessionUrl(args); new HTTP.Request(url, method, format).Send(request => { //check for error Hashtable obj = request.response.Object; if (obj != null) { if (obj.ContainsKey("error_code")) { string errorCode = obj["error_code"].ToString(); string errorMsg = obj["error_msg"].ToString(); switch (errorCode) { case "100": if (errorMsg == "PARAM : Missed required parameter: access_token") { Debug.Log("Missing access token - trying to auto refresh session"); RefreshAuth(refreshed => { Debug.Log("REFRESHED: " + refreshed); }); } break; case "102": Debug.Log("Session expired - trying to auto refresh session"); RefreshAuth(refreshed => { Debug.Log("REFRESHED: " + refreshed); }); break; case "103": Debug.Log("Invalid session key - trying to auto refresh session"); RefreshAuth(refreshed => { Debug.Log("REFRESHED: " + refreshed); }); break; default: Debug.LogWarning(query + " failed -> " + request.response.Error); callback(request.response); break; } return; } } if (callback != null) { callback(request.response); } }); }
public bool OpenSuggestDialog(OKRequestCallback callback, string defaultMessage, string[] selected) { return(OpenSuggestDialog(callback, null, defaultMessage, selected)); }
public void GetFriendsByDevices(OKRequestCallback callback, string[] devices) { Api(OKMethod.Friends.getByDevices, new Dictionary<string, string> { {"devices", string.Join(",", devices)} }, callback ); }
public bool OpenPhotoDialog(OKRequestCallback callback, Texture2D image, string defaultComment) { return(OpenPhotoDialog(callback, null, image, defaultComment)); }
public static void API(string query, Method method, Dictionary <string, string> args, OKRequestCallback callback, bool useSession = true) { OdnoklassnikiImpl.Api(query, method, args, callback, useSession); }
public void Api(string query, HTTP.Method method, Dictionary<string, string> args, OKRequestCallback callback, bool useSession = true) { Api(query, method, httpFormat, args, callback, useSession); }
public bool OpenSuggestDialog(OKRequestCallback callback, string defaultMessage, string[] selected) { return OpenSuggestDialog(callback, null, defaultMessage, selected); }