////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
//using System.Drawing;
using System.IO;
/////////Google data ///////////////////////
using Google.GData.Photos;
using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Extensions.Location;
using Google.GData.AccessControl;
namespace Picasa_upload
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
PicasaService service = new PicasaService("Testing-quliatas-1");///intial service
public MainWindow()
{
InitializeComponent();
}
///
/// uploading image
///
///
public void uploading_image(string name)
{
try
{
AlbumQuery myAlbumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri(name));
PicasaFeed myPicasaFeed = service.Query(myAlbumQuery);
string album_id = null;
string album_name = null;
foreach (PicasaEntry p in myPicasaFeed.Entries)
{
AlbumAccessor myAlbum = new AlbumAccessor(p);
string a = "album=" + myAlbum.AlbumTitle.ToString() + " album_id=" + myAlbum.Id.ToString() + " no_of_photos=" + myAlbum.NumPhotos.ToString();
album_id = myAlbum.Id.ToString();
album_name = myAlbum.AlbumTitle.ToString();
}
Uri postUri = new Uri(PicasaQuery.CreatePicasaUri(name, album_id));
System.IO.FileInfo fileInfo = new System.IO.FileInfo("D:\\1.bmp");
System.IO.FileStream fileStream = fileInfo.OpenRead();
PicasaEntry entry = (PicasaEntry)service.Insert(postUri, fileStream, "image/bmp","1");
fileStream.Close();
/* PhotoQuery photos = new PhotoQuery();
PicasaFeed picasaFeed = null;
photos.Uri = new Uri(PicasaQuery.CreatePicasaUri(name, album_name)); //service is a PicasaService object, with credentials set
picasaFeed = (PicasaFeed)service.Query(photos);
Uri postUri = new Uri(picasaFeed.Post);
//PicasaEntry entry = service.Insert(postUri, new MemoryStream(bFile), "image/jpeg", fileUpload.FileName) as PicasaEntry; // save the file at picasa*/
}
catch (AuthenticationException authE)
{
MessageBox.Show(authE.Message, "Falied in uploading",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
catch (Exception errE)
{
MessageBox.Show(errE.Message, "Error",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
///
/// /////////login id /////////////////////////////
///
///
///
///
private void authenticateUser(string username, string password, string name)
{
try
{
PicasaService myPicasa = new PicasaService("Qualitas-test");
myPicasa.setUserCredentials(username, password);
}
catch (AuthenticationException authE)
{
MessageBox.Show(authE.Message, "Invalid username/password",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
catch (Exception errE)
{
MessageBox.Show(errE.Message, "Error",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
private void upload_Click(object sender, RoutedEventArgs e)
{
authenticateUser("[email protected]", "livehappy", "rjgowth11");
addnewalbum("title", "Text", "rjgowth11");
//uploading_image("rjgowth11");
}
private void addnewalbum(string title, string Text, string username)
{
try
{
//AlbumQuery myAlbumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri(username));
// PicasaFeed myPicasaFeed = service.Query(myAlbumQuery);
AlbumEntry newAlbum = new AlbumEntry();
newAlbum.Title.Text = title;
newAlbum.Summary.Text = Text;
AlbumAccessor ac = new AlbumAccessor(newAlbum);
//set to "private" for a private album
ac.Access = "private";
PicasaEntry newEntry = (PicasaEntry)service.Insert(myPicasaFeed, newAlbum);
/* AlbumEntry newEntry = new AlbumEntry();
newEntry.Title.Text = title;
newEntry.Summary.Text = Text;
AlbumAccessor ac = new AlbumAccessor(newEntry);
//set to "private" for a private album
ac.Access = "private";
Uri feedUri = new Uri(PicasaQuery.CreatePicasaUri(username));
PicasaEntry newAlbum = (PicasaEntry)service.Insert(feedUri, newEntry);*/
// PicasaEntry createdEntry = (PicasaEntry)service.Insert(feedUri, newEntry);*/
/*AlbumQuery myAlbumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri(username));
PicasaFeed myPicasaFeed = service.Query(myAlbumQuery);
AlbumEntry Entry = new AlbumEntry();
Entry.Title.Text = title;
Entry.Summary.Text = Text;
PicasaEntry newEntry = (PicasaEntry)service.Insert(myPicasaFeed,Entry);*/
///////////////////////////error in uploading///////////////////////////////////////
// ?kind=album;
/* AlbumQuery myAlbumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri(username));
PicasaFeed myPicasaFeed = service.Query(myAlbumQuery);
/* PicasaEntry newEntry = (PicasaEntry)service.Insert(myPicasaFeed, newAlbum);*/
/* FeedQuery query = new FeedQuery("http://picasaweb.google.com/data/feed/api/user/" + "rjgowth11" + "?kind=album");
AtomFeed calFeed = service.Query(query);*/
////////////////////////////////////////////////////////////////////////////////////////
}
catch (Exception errE)
{
MessageBox.Show(errE.Message, "Error",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
}
}
////////////////////////////////////////////////////////////////////
Shweta LodhaPosted Dec 29, 2014, 10:50 AM
https://developers.google.com/picasa-web/docs/2.0/developers_guide_protocol
RJ GowthamPosted Dec 29, 2014, 5:20 AM
Is there is authentication token is require to upload a image in the picasa. Please Provide some examples of private Feed.
Shweta LodhaPosted Dec 27, 2014, 10:54 AM
I didn't get chance to go through your code complete, but I guess you may be using the basic feed, which are always readonly. Try using a feed URL ending in
private/fullorprivate/full-noattendees.