Exemplo n.º 1
0
    public void getAttributes(string audience_email)
    {
        try{
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (s,ce,ca,p) => true;

            /*------------------------------- Edit the information below ------------------------*/

            string CONDUCTTR_PROJECT_ID = "";
            string CONDUCTTR_CONSUMER_KEY = "";
            string CONDUCTTR_CONSUMER_SECRET = "";
            string CONDUCTTR_CONSUMER_ACCESS_TOKEN = "";
            string CONDUCTTR_CONSUMER_ACCESS_TOKEN_SECRET = "";
            string CONDUCTTR_API_GET_METHOD = "";

            /*------------------------------- Edit the information above ------------------------*/

            Uri URL = new Uri("https://api.conducttr.com/v1/project/" + CONDUCTTR_PROJECT_ID + "/" + CONDUCTTR_API_GET_METHOD + "?audience_email=" + audience_email);

            var config = new OAuthConfig() { ConsumerKey=CONDUCTTR_CONSUMER_KEY, ConsumerSecret=CONDUCTTR_CONSUMER_SECRET };
            OAuthAuthorizer auth = new OAuthAuthorizer(config);
            auth.AccessToken = CONDUCTTR_CONSUMER_ACCESS_TOKEN;
            auth.AccessTokenSecret = CONDUCTTR_CONSUMER_ACCESS_TOKEN_SECRET;

            //string json = "";
            WWW www=GET(URL.ToString()+"&"+OAuthAuthorizer.AuthorizeRequest2(config, CONDUCTTR_CONSUMER_ACCESS_TOKEN, CONDUCTTR_CONSUMER_ACCESS_TOKEN_SECRET, "GET", URL, null));

        }
        catch(Exception e){
            Debug.Log (e.Message + " : " + e.StackTrace);
            //status.text = e.Message;
        }
    }
Exemplo n.º 2
0
    public void setAttributes(string attribute1, string attribute2, string attribute3)
    {
        try{
            //ServicePointManager.ServerCertificateValidationCallback =ValidateServerCertficate;
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (s,ce,ca,p) => true;

            /*------------------------------- Edit the information below ------------------------*/

            string CONDUCTTR_PROJECT_ID = "";
            string CONDUCTTR_CONSUMER_KEY = "";
            string CONDUCTTR_CONSUMER_SECRET = "";
            string CONDUCTTR_CONSUMER_ACCESS_TOKEN = "";
            string CONDUCTTR_CONSUMER_ACCESS_TOKEN_SECRET = "";

            string CONDUCTTR_API_POST_METHOD = "";

            /*------------------------------- Edit the information above ------------------------*/

            Uri URL = new Uri("https://api.conducttr.com/v1/project/" + CONDUCTTR_PROJECT_ID + "/" + CONDUCTTR_API_POST_METHOD);

            Dictionary<string,string> requestParameters=new Dictionary<string,string>();
            requestParameters["audience_email"]=audience_email;

            /* Add the attributes to the API Call */
            requestParameters["attribute1"]=attribute1;
            requestParameters["attribute2"]=attribute2;
            requestParameters["attribute3"]=attribute3;

            var config = new OAuthConfig() { ConsumerKey=CONDUCTTR_CONSUMER_KEY, ConsumerSecret=CONDUCTTR_CONSUMER_SECRET };
            OAuthAuthorizer auth = new OAuthAuthorizer(config);
            auth.AccessToken = CONDUCTTR_CONSUMER_ACCESS_TOKEN;
            auth.AccessTokenSecret = CONDUCTTR_CONSUMER_ACCESS_TOKEN_SECRET;

            //prepare request parameters
            string parameters="";
            foreach(string key in requestParameters.Keys) parameters+=key+"="+requestParameters[key]+"&";
            if (requestParameters.Keys.Count>0) parameters.Substring(0,parameters.Length-1);
            Dictionary<string, string> postParameters=OAuthAuthorizer.AuthorizeRequest3(config, CONDUCTTR_CONSUMER_ACCESS_TOKEN, CONDUCTTR_CONSUMER_ACCESS_TOKEN_SECRET, "POST",URL, parameters);

            foreach(string key in requestParameters.Keys) postParameters[key]=requestParameters[key];

            WWW www=POST(URL.ToString(),postParameters);

        }
        catch(Exception e){
            Debug.Log (e.Message + " : " + e.StackTrace);
            status.text = e.Message + " : " + e.StackTrace;
        }
    }