A Hyves session represents a logical user login, and allows an application to access Hyves services in the context of the specific user.
        /// <summary>
        /// Creates an new instance of a request with the specified session.
        /// </summary>
        /// <param name="session">The session to use to issue the request.</param>
        public HyvesRequest(HyvesSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            this.session = session;
            parameters   = new HyvesRequestParameterList();
        }
    /// <summary>
    /// Creates an new instance of a request with the specified session.
    /// </summary>
    /// <param name="session">The session to use to issue the request.</param>
    public HyvesRequest(HyvesSession session)
    {
      if (session == null)
      {
        throw new ArgumentNullException("session");
      }

      this.session = session;
      parameters = new HyvesRequestParameterList();
    }
		internal FancyLayoutService(HyvesSession session)
		{
			Debug.Assert(session != null);
			this.session = session;
		}
		internal HubCategoriesService(HyvesSession session)
		{
			Debug.Assert(session != null);
			this.session = session;
		}
    private static HttpWebRequest CreateRequest(HyvesMethod method, bool useFancyLayout, int page, int resultsPerPage, HyvesSession session, HyvesRequestParameterList parameters)
    {
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(HyvesHttpUri);
      parameters.InitializeRequest(request, method, useFancyLayout, page, resultsPerPage, session);

      return request;
    }
コード例 #6
0
 internal void InitializeRequest(HttpWebRequest request, HyvesMethod method, int page, int resultsPerPage, HyvesSession session)
 {
     InitializeRequest(request, method, false, page, resultsPerPage, session);
 }
        private static HttpWebRequest CreateRequest(HyvesMethod method, bool useFancyLayout, int page, int resultsPerPage, HyvesSession session, HyvesRequestParameterList parameters)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(HyvesHttpUri);

            parameters.InitializeRequest(request, method, useFancyLayout, page, resultsPerPage, session);

            return(request);
        }
 private static HttpWebRequest CreateRequest(HyvesMethod method, HyvesSession session, HyvesRequestParameterList parameters)
 {
     return(CreateRequest(method, session, parameters));
 }
		/// <summary>
		/// Initializes an instance of a HyvesService with the specified
		/// session.
		/// </summary>
		/// <param name="session">The session associated with requests issued to the service.</param>
		public HyvesService(HyvesSession session)
		{
			if (session == null)
			{
				throw new ArgumentNullException("session");
			}

      this.session = session;
		}
		internal AuthenticationService(HyvesSession session)
		{
			Debug.Assert(session != null);
      this.session = session;
		}
		internal PrivateSpotsService(HyvesSession session)
		{
			Debug.Assert(session != null);
			this.session = session;
		}
コード例 #12
0
        private void SetRequestMetadata(HttpWebRequest request, HyvesMethod method, bool useFancyLayout, int page, int resultsPerPage, HyvesSession session)
        {
            string url = request.RequestUri.ToString();

            this["ha_method"]      = EnumHelper.GetDescription(method);
            this["ha_version"]     = session.Version;
            this["ha_format"]      = "json";
            this["ha_fancylayout"] = useFancyLayout.ToString().ToLower();
            if (page > 0)
            {
                this["ha_page"] = page.ToString();
            }

            if (resultsPerPage > 0)
            {
                this["ha_resultsperpage"] = resultsPerPage.ToString();
            }

            StringBuilder requestBuilder = new StringBuilder(512);

            foreach (KeyValuePair <string, string> param in this)
            {
                if (requestBuilder.Length != 0)
                {
                    requestBuilder.Append("&");
                }

                requestBuilder.Append(param.Key);
                requestBuilder.Append("=");
                requestBuilder.Append(param.Value);
            }

            string timeStamp = oauth.GenerateTimeStamp();
            string nonce     = this.oauth.GenerateNonce();

            if (string.IsNullOrEmpty(session.Token) == false)
            {
                this["oauth_token"] = session.Token;
            }

            this["oauth_consumer_key"]     = session.ConsumerKey;
            this["oauth_timestamp"]        = timeStamp;
            this["oauth_nonce"]            = nonce;
            this["oauth_version"]          = "1.0";
            this["oauth_signature_method"] = "HMAC-SHA1";

            this["oauth_signature"] = this.oauth.GenerateSignature(new Uri(url), this, session.ConsumerKey, session.ConsumerSecret, session.Token, session.TokenSecret, request.Method, timeStamp, nonce);
        }
コード例 #13
0
        internal void InitializeRequest(HttpWebRequest request, HyvesMethod method, bool useFancyLayout, int page, int resultsPerPage, HyvesSession session)
        {
            request.Method = "POST";

            SetRequestMetadata(request, method, useFancyLayout, page, resultsPerPage, session);

            InitializeFormRequest(request);
        }
コード例 #14
0
 internal void InitializeRequest(HttpWebRequest request, HyvesMethod method, bool useFancyLayout, HyvesSession session)
 {
     InitializeRequest(request, method, useFancyLayout, -1, -1, session);
 }
		internal BuzzService(HyvesSession session)
		{
			Debug.Assert(session != null);
			this.session = session;
		}
        private static HttpWebRequest CreateRequest(string requestToken, string requestTokenSecret, HyvesExpirationType expirationType, HyvesSession session)
        {
            HyvesRequestParameterList parameters = new HyvesRequestParameterList();
            HyvesMethod method;

            if (string.IsNullOrEmpty(requestToken))
            {
                method = HyvesMethod.AuthRequesttoken;

                StringBuilder methodsStringBuilder = new StringBuilder();

                if (session.Methods.Contains(HyvesMethod.All))
                {
                    Array hyvesMethodValues = Enum.GetValues(typeof(HyvesMethod));
                    foreach (HyvesMethod hyvesMethod in hyvesMethodValues)
                    {
                        if (hyvesMethod != HyvesMethod.Unknown)
                        {
                            methodsStringBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(hyvesMethod)));
                        }
                    }

                    methodsStringBuilder = methodsStringBuilder.Replace(
                        string.Format("{0},", EnumHelper.GetDescription(HyvesMethod.All)),
                        string.Empty);
                }
                else
                {
                    foreach (HyvesMethod hyvesMethod in session.Methods)
                    {
                        methodsStringBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(hyvesMethod)));
                    }
                }

                string methods = methodsStringBuilder.ToString();
                parameters["methods"] = methods.Substring(0, methods.Length - 1);

                parameters["expirationtype"] = EnumHelper.GetDescription(expirationType);
            }
            else
            {
                session.InitializeToken(requestToken, requestTokenSecret, DateTime.MinValue);
                method = HyvesMethod.AuthAccesstoken;
            }

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(HyvesHttpUri);

            parameters.InitializeRequest(request, method, session);

            return(request);
        }
    private static HttpWebRequest CreateRequest(string requestToken, string requestTokenSecret, HyvesExpirationType expirationType, HyvesSession session)
    {
      HyvesRequestParameterList parameters = new HyvesRequestParameterList();
      HyvesMethod method;

      if (string.IsNullOrEmpty(requestToken))
      {
        method = HyvesMethod.AuthRequesttoken;

        StringBuilder methodsStringBuilder = new StringBuilder();

        if (session.Methods.Contains(HyvesMethod.All))
        {
          Array hyvesMethodValues = Enum.GetValues(typeof(HyvesMethod));
          foreach (HyvesMethod hyvesMethod in hyvesMethodValues)
          {
            if (hyvesMethod != HyvesMethod.Unknown)
            {
              methodsStringBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(hyvesMethod)));
            }
          }

          methodsStringBuilder=methodsStringBuilder.Replace(
            string.Format("{0},", EnumHelper.GetDescription(HyvesMethod.All)),
            string.Empty);
        }
        else
        {
          foreach (HyvesMethod hyvesMethod in session.Methods)
          {
            methodsStringBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(hyvesMethod)));
          }
        }

        string methods = methodsStringBuilder.ToString();
        parameters["methods"] = methods.Substring(0, methods.Length - 1);

        parameters["expirationtype"] = EnumHelper.GetDescription(expirationType);
      }
      else
      {
        session.InitializeToken(requestToken, requestTokenSecret, DateTime.MinValue);
        method = HyvesMethod.AuthAccesstoken;
      }

      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(HyvesHttpUri);
      parameters.InitializeRequest(request, method, session);

      return request;
    }
 private static HttpWebRequest CreateRequest(HyvesMethod method, bool useFancyLayout, HyvesSession session, HyvesRequestParameterList parameters)
 {
     return(CreateRequest(method, useFancyLayout, session, parameters));
 }
 private static HttpWebRequest CreateRequest(HyvesMethod method, HyvesSession session, HyvesRequestParameterList parameters)
 {
   return CreateRequest(method, session, parameters);
 }
 private static HttpWebRequest CreateRequest(HyvesMethod method, bool useFancyLayout, HyvesSession session, HyvesRequestParameterList parameters)
 {
   return CreateRequest(method, useFancyLayout, session, parameters);
 }
コード例 #21
0
 internal void InitializeRequest(HttpWebRequest request, HyvesMethod method, HyvesSession session)
 {
     InitializeRequest(request, method, false, -1, -1, session);
 }