public MultipartRequest (GoogleConnection conn, string url)
		{
			request = conn.AuthenticatedRequest (url);
			request.Method = "POST";
			request.ContentType = "multipart/related; boundary=\"" + separator_string + "\"";
			request.Headers.Add ("MIME-version", "1.0");
		}
 public MultipartRequest(GoogleConnection conn, string url)
 {
     Request             = conn.AuthenticatedRequest(url);
     Request.Method      = "POST";
     Request.ContentType = "multipart/related; boundary=\"" + separator_string + "\"";
     Request.Headers.Add("MIME-version", "1.0");
 }
 // args [0] -> user name, args [1] -> album title
 static void Main(string [] args)
 {
     ServicePointManager.ServerCertificateValidationCallback +=  delegate { return true; };
     GoogleConnection conn = new GoogleConnection (GoogleService.Picasa);
     Console.Write ("Password: "******"Album created. Title: {0} Unique ID: {1}", album.Title, album.UniqueID);
 }
		public PicasaWeb Connect ()
		{
			System.Console.WriteLine ("GoogleAccount.Connect()");
			GoogleConnection conn = new GoogleConnection (GoogleService.Picasa);
			ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy ();
			if (unlock_captcha == null || token == null)
				conn.Authenticate(username, password);
			else {
				conn.Authenticate(username, password, token, unlock_captcha);
				token = null;
				unlock_captcha = null;
			}
			connection = conn;
			PicasaWeb picasa = new PicasaWeb(conn);
			this.picasa = picasa;
			return picasa;
		}
    static void Main(string [] args)
    {
        string user = args [0];
        string albumid = args [1];
        string imageid = args [2];
        string tag = args [3];
        Console.Write ("Password: "******"")
            password = null;

        ServicePointManager.ServerCertificateValidationCallback +=  delegate { return true; };
        GoogleConnection conn = new GoogleConnection (GoogleService.Picasa);
        conn.Authenticate (user, password);
        PicasaPicture picture = new PicasaPicture (conn, albumid, imageid);
        Console.WriteLine ("  Image Name: {0} ID: {1}", picture.Title, picture.UniqueID);
        picture.AddTag (tag);
    }
    static void Main(string [] args)
    {
        Console.Write ("User name: ");
        string user = Console.ReadLine ();
        Console.Write ("Password: "******"")
            picasa = new PicasaWeb (conn, user);
        else {
            conn.Authenticate (user, password);
            picasa = new PicasaWeb (conn);
        }
        Console.WriteLine ("Picasa: Title: {0}, User: {1}, NickName: {2}, QuotaUsed: {3}, QuotaLimit: {4}\n", picasa.Title, picasa.User, picasa.NickName, picasa.QuotaUsed, picasa.QuotaLimit);
        PicasaAlbumCollection coll = picasa.GetAlbums ();
        foreach (PicasaAlbum album in coll.AllValues) {
            Console.WriteLine ("Title: {0} ID: {1}", album.Title, album.UniqueID);
        }
    }
    static void Main(string [] args)
    {
        string user = args [0];
        string albumid = args [1];
        string filepath = args [2];
        Console.Write ("Password: "******"")
            password = null;

        ServicePointManager.ServerCertificateValidationCallback +=  delegate { return true; };
        GoogleConnection conn = new GoogleConnection (GoogleService.Picasa);
        conn.Authenticate (user, password);
        PicasaAlbum album = new PicasaAlbum (conn, albumid);
        Console.WriteLine ("  Album Title: {0} ID: {1}", album.Title, album.UniqueID);
        string [] files = Directory.GetFiles (filepath, "*.jpg");
        int count = files.Length;
        int i = 0;
        foreach (string f in files) {
            i++;
            Console.WriteLine ("Uploading {0} ({1} of {2})", Path.GetFileName (f), i, count);
            album.UploadPicture (f);
        }
    }
Exemple #8
0
 private void MarkChanged()
 {
     connection = null;
 }
        public static string GetAuthorization(GoogleConnection conn, string email, string password,
                                              GoogleService service, string token, string captcha)
        {
            if (email == null || email == String.Empty || password == null || password == String.Empty)
            {
                return(null);
            }

            email    = HttpUtility.UrlEncode(email);
            password = HttpUtility.UrlEncode(password);
            string appname      = HttpUtility.UrlEncode(conn.ApplicationName);
            string service_code = service.ServiceCode;

            StringBuilder content = new StringBuilder();

            content.Append("accountType=HOSTED_OR_GOOGLE");
            content.AppendFormat("&Email={0}", email);
            content.AppendFormat("&Passwd={0}", password);
            content.AppendFormat("&email={0}", email);
            content.AppendFormat("&service={0}", service_code);
            content.AppendFormat("&source={0}", appname);

            if (token != null)
            {
                content.AppendFormat("&logintoken={0}", token);
                content.AppendFormat("&logincaptcha={0}", captcha);
            }
            byte [] bytes = Encoding.UTF8.GetBytes(content.ToString());

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

            request.Method        = "POST";
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = bytes.Length;

            Stream output = request.GetRequestStream();

            output.Write(bytes, 0, bytes.Length);
            output.Close();

            HttpWebResponse response = null;

            try {
                response = (HttpWebResponse)request.GetResponse();
            } catch (WebException wexc) {
                response = wexc.Response as HttpWebResponse;
                if (response == null)
                {
                    throw;
                }
                ThrowOnError(response);
                throw;                 // if the method above does not throw, we do
            }

            //string sid = null;
            //string lsid = null;
            string auth = null;

            using (Stream stream = response.GetResponseStream()) {
                StreamReader sr = new StreamReader(stream, Encoding.UTF8);
                string       s;
                while ((s = sr.ReadLine()) != null)
                {
                    if (s.StartsWith("Auth="))
                    {
                        auth = s.Substring(5);
                    }
                    //else if (s.StartsWith ("LSID="))
                    //	lsid = s.Substring (5);
                    //else if (s.StartsWith ("SID="))
                    //	sid = s.Substring (4);
                }
            }
            response.Close();

            return(auth);
        }
		public static string GetAuthorization (GoogleConnection conn, string email, string password,
				GoogleService service, string token, string captcha)
		{
			if (email == null || email == String.Empty || password == null || password == String.Empty)
				return null;

			email = HttpUtility.UrlEncode (email);
			password = HttpUtility.UrlEncode (password);
			string appname = HttpUtility.UrlEncode (conn.ApplicationName);
			string service_code = service.ServiceCode;

			StringBuilder content = new StringBuilder ();
			content.Append ("accountType=HOSTED_OR_GOOGLE");
			content.AppendFormat ("&Email={0}", email);
			content.AppendFormat ("&Passwd={0}", password);
			content.AppendFormat ("&email={0}", email);
			content.AppendFormat ("&service={0}", service_code);
			content.AppendFormat ("&source={0}", appname);

			if (token != null) {
				content.AppendFormat ("&logintoken={0}", token);
				content.AppendFormat ("&logincaptcha={0}", captcha);
			}
			byte [] bytes = Encoding.UTF8.GetBytes (content.ToString ());

			HttpWebRequest request = (HttpWebRequest) WebRequest.Create (client_login_url);
			request.Method = "POST";
			request.ContentType = "application/x-www-form-urlencoded";
			request.ContentLength = bytes.Length;

			Stream output = request.GetRequestStream ();
			output.Write (bytes, 0, bytes.Length);
			output.Close ();

			HttpWebResponse response = null;
			try {
				response = (HttpWebResponse) request.GetResponse ();
			} catch (WebException wexc) {
				response = wexc.Response as HttpWebResponse;
				if (response == null)
					throw;
				ThrowOnError (response);
				throw; // if the method above does not throw, we do
			}

			//string sid = null;
			//string lsid = null;
			string auth = null;

			using (Stream stream = response.GetResponseStream ()) {
				StreamReader sr = new StreamReader (stream, Encoding.UTF8);
				string s;
				while ((s = sr.ReadLine ()) != null) {
					if (s.StartsWith ("Auth="))
						auth = s.Substring (5);
					//else if (s.StartsWith ("LSID="))
					//	lsid = s.Substring (5);
					//else if (s.StartsWith ("SID="))
					//	sid = s.Substring (4);
				}
			}
			response.Close ();

			return auth;
		}
 public void login()
 {
     try {
         connection = new GoogleConnection(GoogleService.Picasa);
         //ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy();
         connection.Authenticate(this.username, this.password);
         web = new PicasaWeb(connection);
         this.loggedIn = true;
     } catch (Exception) {
         this.loggedIn = false;
     }
 }