我有点难过,因为Flickr文档提到了收藏和画廊,但我找不到与专辑有关的内容。
我正在asp.net中建立一个网站,并希望从我拥有的Flickr相册中加载照片,经过一段时间检查收藏和画廊API没有运气我希望有人知道如何从Flickr相册中检索照片
这是我目前所拥有的,它适用于我的照片流中的照片,但我还没弄明白如何加载相册。
using System;
using System.Configuration;
using System.Web;
using FlickrNet;
namespace MyWebSite.Core.Gateways
{
public class FlickrGateway : IFlickrGateway
{
private readonly string _flickrApiKey = ConfigurationManager.AppSettings["Flickr.ApiKey"];
private readonly string _flickrApiSecret = ConfigurationManager.AppSettings["Flickr.ApiSecret"];
private readonly string _flickrApiUserId = ConfigurationManager.AppSettings["Flickr.ApiUserId"];
private readonly string _flickrPhotoSetId = ConfigurationManager.AppSettings["Flickr.PhotoSetId"];
private readonly Flickr _flickrApi;
public FlickrGateway()
{
_flickrApi = new Flickr(_flickrApiKey, _flickrApiSecret) { InstanceCacheDisabled = true };
if (OAuthToken == null) return;
_flickrApi.OAuthAccessToken = OAuthToken.Token;
_flickrApi.OAuthAccessTokenSecret = OAuthToken.TokenSecret;
}
public PhotoCollection GetPhotoStream()
{
return _flickrApi.PeopleGetPublicPhotos(_flickrApiUserId);
}
public PhotosetCollection GetPhotosetsList()
{
return _flickrApi.PhotosetsGetList(_flickrApiUserId);
}
public PhotosetPhotoCollection GetPhotoSet(string photoSetId)
{
return _flickrApi.PhotosetsGetPhotos(photoSetId);
}
public PhotosetPhotoCollection GetPhotoSet()
{
return _flickrApi.PhotosetsGetPhotos(_flickrPhotoSetId);
}
private static OAuthAccessToken OAuthToken
{
get
{
if (HttpContext.Current.Request.Cookies["OAuthToken"] == null)
{
return null;
}
var values = HttpContext.Current.Request.Cookies["OAuthToken"].Values;
return new OAuthAccessToken
{
FullName = values["FullName"],
Token = values["Token"],
TokenSecret = values["TokenSecret"],
UserId = values["UserId"],
Username = values["Username"]
};
}
set
{
var cookie = new HttpCookie("OAuthToken")
{
Expires = DateTime.UtcNow.AddHours(1),
};
cookie.Values["FullName"] = value.FullName;
cookie.Values["Token"] = value.Token;
cookie.Values["TokenSecret"] = value.TokenSecret;
cookie.Values["UserId"] = value.UserId;
cookie.Values["Username"] = value.Username;
HttpContext.Current.Response.AppendCookie(cookie);
}
}
}
}
答案 0 :(得分:0)
要获取相册照片,您需要调用flickr.photosets.getPhotos API方法。
.Net API中的相应方法是Flickr_Photosets.PhotosetsGetPhotos
。
我可以看到你已经拥有它:GetPhotoSet
。
所以您只需要将albumId
作为photoSetId
传递。