public BCAccount(AccountConfigElement AccountConfig) { Name = AccountConfig.Name; PublisherID = AccountConfig.PublisherID; Type = AccountConfig.Type; ReadToken = AccountConfig.ReadToken; ReadTokenURL = AccountConfig.ReadTokenURL; ReadURL = AccountConfig.ReadURL; WriteToken = AccountConfig.WriteToken; WriteURL = AccountConfig.WriteURL; }
public BCAccount(AccountConfigElement AccountConfig) { Name = AccountConfig.Name; PublisherID = AccountConfig.PublisherID; Type = AccountConfig.Type; ReadToken = AccountConfig.ReadToken; ReadTokenURL = AccountConfig.ReadTokenURL; ReadURL = AccountConfig.ReadURL; WriteToken = AccountConfig.WriteToken; WriteURL = AccountConfig.WriteURL; }
public static String BuildReadQuery(Dictionary <String, String> reqParams, AccountConfigElement a) { String reqUrl = ""; //append url tokens and count if necessary reqUrl += a.ReadURL.Value; reqUrl += "?token=" + a.ReadToken.Value; reqUrl += "&get_item_count=true"; foreach (String key in reqParams.Keys) { reqUrl += "&" + String.Format("{0}={1}", key, HttpUtility.UrlEncode(reqParams[key])); } return(reqUrl); }
public static String BuildReadQuery(List <KeyValuePair <String, String> > reqParams, AccountConfigElement a) { String reqUrl = ""; //append url tokens and count if necessary reqUrl += a.ReadURL.Value; reqUrl += "?token=" + a.ReadToken.Value; reqUrl += "&get_item_count=true"; foreach (KeyValuePair <String, String> item in reqParams) { reqUrl += String.Format("&{0}={1}", item.Key, HttpUtility.UrlEncode(item.Value)); } return(reqUrl); }
public static RPCResponse ExecuteWrite(Dictionary <String, Object> postParams, AccountConfigElement a) { // Create request and receive response HttpWebResponse webResponse = PostRequests.MultipartFormDataPost(a.WriteURL.Value, "BCAPI SDK Write Request", postParams); // Process response StreamReader responseReader = new StreamReader(webResponse.GetResponseStream()); string jsonResult = responseReader.ReadToEnd(); webResponse.Close(); //this is so that we don't cast null as an object (replaces null with empty error) jsonResult = jsonResult.Replace("\"error\": null", "\"error\": { \"name\" : null, \"message\" : null, \"code\" : null }"); RPCResponse rpcr = JSON.Converter.Deserialize <RPCResponse>(jsonResult); return(rpcr); }
public static QueryResultPair ExecuteRead(Dictionary <String, String> reqParams, AccountConfigElement a) { String reqUrl = BuildReadQuery(reqParams, a); HttpWebRequest webRequest = WebRequest.Create(reqUrl) as HttpWebRequest; HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse; TextReader textreader = new StreamReader(response.GetResponseStream()); string jsonStr = textreader.ReadToEnd(); QueryResultPair qrp = new QueryResultPair(reqUrl, jsonStr); return(qrp); }
public void InitApiConnection(IVideoCloudConfig configProvider) { if (configProvider == null) { return; } else { try { if (string.IsNullOrEmpty(configProvider.PublisherId) || string.IsNullOrEmpty(configProvider.ReadToken) || string.IsNullOrEmpty(configProvider.WriteToken)) { return; } } catch { return; } } try { this.accountConfig = new AccountConfigElement("brightcove"); this.accountConfig.PublisherID = Convert.ToInt64(configProvider.PublisherId); this.readTokenList = configProvider.ReadToken.Split(tokenDelim); this.writeTokenList = configProvider.WriteToken.Split(tokenDelim); if (this.readTokenList.Length > 0) { this.accountConfig.ReadToken.Value = this.readTokenList[0]; } else { this.accountConfig.ReadToken.Value = configProvider.ReadToken; } if (this.writeTokenList.Length > 0) { this.accountConfig.WriteToken.Value = this.writeTokenList[0]; } else { this.accountConfig.WriteToken.Value = configProvider.WriteToken; } this.accountConfig.ReadURL.Value = configProvider.ReadUrl; this.accountConfig.WriteURL.Value = configProvider.WriteUrl; // Set default values for player this.DefaultVideoPlayerId = configProvider.DefaultVideoPlayerId; this.DefaultPlaylistPlayerId = configProvider.DefaultPlaylistPlayerId; } catch { // Alert user there is a problem with their site settings //throw new Exception("Brightcove Configuration is not setup. Please enter your Brightcove Video Cloud account settings in this site's Site Settings."); return; } ResetApiConnection(); }