public static void Authorize(this FlickrNet.Flickr flickr, OAuthAccessToken accessToken) { if (!IsComplete(accessToken)) throw new AuthorizationException(); flickr.OAuthAccessToken = accessToken.Token; flickr.OAuthAccessTokenSecret = accessToken.TokenSecret; }
public IEnumerable<Photo> GetItems(string setName, OAuthAccessToken accessToken) { if (accessToken == null) throw new ArgumentNullException("accessToken"); _flickr.Authorize(accessToken); if (string.IsNullOrEmpty(setName)) { var publicPhotos = _flickr.PeopleGetPublicPhotos(accessToken.UserId); return publicPhotos .Select(Map); } var photoSets = _flickr.PhotosetsGetList(); var photoSet = photoSets .SingleOrDefault(p => p.Title == setName); if (photoSet == null) { return new List<Photo>(); } var photos = _flickr.PhotosetsGetPhotos(photoSet.PhotosetId); return photos .Select(Map); }
public static OAuthAccessToken CreateSingle() { var entity = new OAuthAccessToken(); entity.FullName = string.Format(CultureInfo.InvariantCulture, "FullName {0}", entity.Id); entity.Token = string.Format(CultureInfo.InvariantCulture, "Token {0}", entity.Id); entity.TokenSecret = string.Format(CultureInfo.InvariantCulture, "TokenSecret {0}", entity.Id); entity.UserId = string.Format(CultureInfo.InvariantCulture, "UserId {0}", entity.Id); entity.Username = string.Format(CultureInfo.InvariantCulture, "Username {0}", entity.Id); return entity; }
public IEnumerable<AudioTrack> GetItems(string setName, OAuthAccessToken accessToken) { var soundCloud = new Api.SoundCloud(_apiKey, accessToken.Token); if (string.IsNullOrEmpty(setName)) { return soundCloud.Me.Tracks.Get() .Select(Map); } return soundCloud.Me.Playlists.Get() .Single(p => p.title == setName) .tracks .Select(Map); }
public AudioTrack GetItem(int id, OAuthAccessToken accessToken) { var soundCloud = new Api.SoundCloud(_apiKey, accessToken.Token); return Map(soundCloud.Tracks[id].Get()); }
public string UploadItem(Stream data, string setName, string title, OAuthAccessToken accessToken) { var soundCloud = new Api.SoundCloud(_apiKey, accessToken.Token); byte[] buffer; using (var ms = new MemoryStream()) { data.CopyTo(ms); buffer = ms.ToArray(); } var track = new Track { asset_data = buffer, title = title }; return soundCloud.Tracks.Post(track).stream_url; }
public string UploadItem(Stream data, string setName, string fileName, OAuthAccessToken accessToken) { if (data == null) throw new ArgumentNullException("data"); if (accessToken == null) throw new ArgumentNullException("accessToken"); _flickr.Authorize(accessToken); var photoId = _flickr.UploadPicture( data, fileName, Path.GetFileNameWithoutExtension(fileName), description: "", tags: "music band", isPublic: true, isFamily: false, isFriend: false, contentType: FlickrNet.ContentType.Photo, safetyLevel: FlickrNet.SafetyLevel.Safe, hiddenFromSearch: FlickrNet.HiddenFromSearch.Visible); if (string.IsNullOrEmpty(setName)) return photoId; var photoSets = _flickr.PhotosetsGetList(); var photoSet = photoSets .SingleOrDefault(p => p.Title == setName); if (photoSet == null) { _flickr.PhotosetsCreate(setName, photoId); } else { _flickr.PhotosetsAddPhoto(photoSet.PhotosetId, photoId); } return photoId; }
public string UploadItem(Stream data, string setName, string title, OAuthAccessToken accessToken) { throw new NotImplementedException(); }
public IEnumerable<Video> GetItems(string setName, OAuthAccessToken accessToken, int page, int pageSize) { throw new NotImplementedException(); }
public Video GetItem(int id, OAuthAccessToken accessToken) { throw new NotImplementedException(); }
private static bool IsComplete(OAuthAccessToken accessToken) { return !(string.IsNullOrEmpty(accessToken.Token) || string.IsNullOrEmpty(accessToken.TokenSecret) || string.IsNullOrEmpty(accessToken.UserId)); }