Ejemplo n.º 1
0
        public string  getKey(string username, string passowrd, Enums.SyncWith SyncWith = Enums.SyncWith.Production)
        {
            string webAddr = "";

            if (SyncWith == Enums.SyncWith.Production)
            {
                webAddr = "http://www.bazaar.social";
            }
            else if (SyncWith == Enums.SyncWith.Playground)
            {
                webAddr = "https://www.test.cognitivo.in/";
            }
            else
            {
                webAddr = "http://localhost:8000/";
            }

            webAddr = webAddr + "login";


            var httpWebRequest = (HttpWebRequest)WebRequest.Create(webAddr);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";

            string postData = "";

            postData += "email=" + username + "&";
            postData += "password="******"application/x-www-form-urlencoded";
            httpWebRequest.ContentLength = data.Length;

            Stream requestStream = httpWebRequest.GetRequestStream();

            requestStream.Write(data, 0, data.Length);
            requestStream.Close();

            HttpWebResponse myHttpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            Stream responseStream = myHttpWebResponse.GetResponseStream();

            StreamReader myStreamReader = new StreamReader(responseStream, Encoding.Default);

            string pageContent = myStreamReader.ReadToEnd();

            myStreamReader.Close();
            responseStream.Close();

            myHttpWebResponse.Close();


            Models.Key MyList = JsonConvert.DeserializeObject <Models.Key>(pageContent);

            return(MyList.access_token);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Cognitivo.API.Download"/> class.
 /// </summary>
 /// <param name="API_Key">API key.</param>
 /// <param name="SyncWith">Select if you want to sync with production server, or just the playground to test..</param>
 public Download(string API_Key, Enums.SyncWith SyncWith = Enums.SyncWith.Production)
 {
     Http.API = API_Key;
     if (SyncWith == Enums.SyncWith.Production)
     {
         Http.Url = "http://bazaar.social/api/";
     }
     else if (SyncWith == Enums.SyncWith.Playground)
     {
         Http.Url = "http://phplaravel-181496-694025.cloudwaysapps.com/api/";
     }
     else
     {
         Http.Url = "http://localhost:8000/api/";
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Cognitivo.API.Upload"/> class.
 /// </summary>
 /// <param name="API_Key">API key.</param>
 /// <param name="SyncWith">Sync with.</param>
 public Upload(string API_Key, Enums.SyncWith SyncWith = Enums.SyncWith.Production)
 {
     Http.API = API_Key;
     if (SyncWith == Enums.SyncWith.Production)
     {
         Http.Url = "https://developer.mercaditu.com/api/";
     }
     else if (SyncWith == Enums.SyncWith.Playground)
     {
         Http.Url = "https://www.test.cognitivo.in/api/";
     }
     else
     {
         Http.Url = "http://localhost:8000/api/";
     }
 }
Ejemplo n.º 4
0
 public Sync(string API_Key, Enums.SyncWith SyncWith = Enums.SyncWith.Production)
 {
     Http.API = API_Key;
     Http.Url = (SyncWith == Enums.SyncWith.Production) ? "https://www.cognitivo.com/api/" : "https://test.cognitivo.in/api/";
 }