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;
        }
    }
    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;
        }
    }
Beispiel #3
0
        //
        // Assign the result to the Authorization header, like this:
        // request.Headers [HttpRequestHeader.Authorization] = AuthorizeRequest (...)
        //
        public static string AuthorizeRequest(OAuthConfig config, string oauthToken, string oauthTokenSecret, string method, Uri uri, string data)
        {
            var headers = new Dictionary<string, string>() {
                { "oauth_consumer_key", config.ConsumerKey },
                { "oauth_nonce", MakeNonce () },
                { "oauth_signature_method", "HMAC-SHA1" },
                { "oauth_timestamp", MakeTimestamp () },
                { "oauth_token", oauthToken },
                { "oauth_version", "1.0" }};
            var signatureHeaders = new Dictionary<string, string>(headers);

            // Add the data and URL query string to the copy of the headers for computing the signature
            if (data != null && data != "")
            {
                var parsed = Nancy.Helpers.HttpUtility.ParseQueryString(data);
                foreach (string k in parsed.Keys)
                {
                    signatureHeaders.Add(k, OAuth.PercentEncode(parsed[k]));
                }
            }

            var nvc = Nancy.Helpers.HttpUtility.ParseQueryString(uri.Query);
            foreach (string key in nvc)
            {
                if (key != null)
                    signatureHeaders.Add(key, OAuth.PercentEncode(nvc[key]));
            }

            string signature = MakeSignature(method, uri.GetLeftPart(UriPartial.Path), signatureHeaders);
            string compositeSigningKey = MakeSigningKey(config.ConsumerSecret, oauthTokenSecret);
            string oauth_signature = MakeOAuthSignature(compositeSigningKey, signature);

            headers.Add("oauth_signature", OAuth.PercentEncode(oauth_signature));

            return HeadersToOAuth(headers);
        }
Beispiel #4
0
 // Constructor for xAuth
 public OAuthAuthorizer(OAuthConfig config, string xAuthUsername, string xAuthPassword)
 {
     this.config = config;
     this.xAuthUsername = xAuthUsername;
     this.xAuthPassword = xAuthPassword;
 }
Beispiel #5
0
 // Constructor for standard OAuth
 public OAuthAuthorizer(OAuthConfig config)
 {
     this.config = config;
 }
Beispiel #6
0
        //
        // Used to authorize an HTTP request going to TwitPic
        //
        public static void AuthorizeTwitPic(OAuthConfig config, HttpWebRequest wc, string oauthToken, string oauthTokenSecret)
        {
            var headers = new Dictionary<string, string>() {
                { "oauth_consumer_key", config.ConsumerKey },
                { "oauth_nonce", MakeNonce () },
                { "oauth_signature_method", "HMAC-SHA1" },
                { "oauth_timestamp", MakeTimestamp () },
                { "oauth_token", oauthToken },
                { "oauth_version", "1.0" },
                //{ "realm", "http://api.twitter.com" }
            };
            string signurl = "http://api.twitter.com/1/account/verify_credentials.xml";
            // The signature is not done against the *actual* url, it is done against the verify_credentials.json one
            string signature = MakeSignature("GET", signurl, headers);
            string compositeSigningKey = MakeSigningKey(config.ConsumerSecret, oauthTokenSecret);
            string oauth_signature = MakeOAuthSignature(compositeSigningKey, signature);

            headers.Add("oauth_signature", OAuth.PercentEncode(oauth_signature));

            wc.Headers.Add("X-Verify-Credentials-Authorization", HeadersToOAuth(headers));
            wc.Headers.Add("X-Auth-Service-Provider", signurl);
        }