在Flickr API文档中,您需要找到字符串的MD5总和以生成[api_sig]值.
如何从字符串生成MD5总和?
Flickr的例子:
串: 000005fab4534d05api_key9a0554259914a86fb9e7eb014e4e5d52permswrite
MD5总和: a02506b31c1cd46c2e0b6380fb94eb3d
是否可以通过api调用或某些脚本从flickr URL获取静态图像URL?
例如:
Flickr URL - > http://www.flickr.com/photos/53067560@N00/2658147888/in/set-72157606175084388/
静态图片网址 - > http://farm4.static.flickr.com/3221/ 2658147888_826edc8465.jpg
我正在使用Flickr API.调用flickr.test.login方法时,默认的JSON结果是:
{
"user": {
"id": "21207597@N07",
"username": {
"_content": "jamalfanaian"
}
},
"stat": "ok"
}
Run Code Online (Sandbox Code Playgroud)
我想将此响应解析为Java对象:
public class FlickrAccount {
private String id;
private String username;
// ... getter & setter ...
}
Run Code Online (Sandbox Code Playgroud)
应该像这样映射JSON属性:
"user" -> "id" ==> FlickrAccount.id
"user" -> "username" -> "_content" ==> FlickrAccount.username
Run Code Online (Sandbox Code Playgroud)
不幸的是,我无法使用Annotations找到一个漂亮,优雅的方法.到目前为止,我的方法是将JSON字符串读入a Map<String, Object>并从那里获取值.
Map<String, Object> value = new ObjectMapper().readValue(response.getStream(),
new TypeReference<HashMap<String, Object>>() {
});
@SuppressWarnings( "unchecked" )
Map<String, Object> user = (Map<String, Object>) value.get("user");
String id = (String) …Run Code Online (Sandbox Code Playgroud) 我正在参加iTunes U Stanford iOS Class,正在开展其中一项任务,以构建一个小小的Flickr应用程序.我收到一个错误,我似乎无法调试出现的错误
*断言失败 - [UITableView _configureCellForDisplay:forIndexPath:],/ SourceCache/UIKit_Sim/UIKit-2280.1/UITableView.m:5336 2012-08-03 10:59:24.596 Assignment 4 [4611:c07](null)libc ++ abi.dylib:终止调用抛出异常
我的tableviewcontroller的代码:
#import "PlacesPhotosTableViewController.h"
@interface PlacesPhotosTableViewController ()
@property (nonatomic) NSDictionary *placeToDisplay;
@property (nonatomic) NSArray *photosInPlace;
@end
@implementation PlacesPhotosTableViewController
@synthesize placeToDisplay = _placeToDisplay;
@synthesize photosInPlace = _photosInPlace;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (id)init
{
self = [super init];
return self;
}
- (id)initWithPlace:(NSDictionary *)place
{
self = [self init];
if (self) …Run Code Online (Sandbox Code Playgroud) 正在寻找一种模仿Flickr API逻辑来使用Google视图的方法.
在Flickr上,我可以调用该flickr.photos.search方法并获取特定位置的所有照片,如下所示:
响应:
<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="ok">
<photos page="1" pages="7673" perpage="100" total="767266">
<photo id="17856165012" owner="91887621@N04" secret="6d2acf3b87" server="7690" farm="8" title="Amsterdam Canal" ispublic="1" isfriend="0" isfamily="0" />
<photo id="17830118816" owner="131827681@N05" secret="ee8b55fc5e" server="7756" farm="8" title="IMG_2209" ispublic="1" isfriend="0" isfamily="0" />
<photo id="17668921970" owner="131827681@N05" secret="bd0061e638" server="8825" farm="9" title="IMG_2210" ispublic="1" isfriend="0" isfamily="0" />
<photo id="17853550052" owner="131827681@N05" secret="c834e9a7eb" server="7738" farm="8" title="IMG_2212" ispublic="1" isfriend="0" isfamily="0" />
<photo id="17856935911" owner="131827681@N05" secret="39be86bb4b" server="7723" farm="8" title="IMG_2213" ispublic="1" isfriend="0" isfamily="0" />
<photo id="17233920844" owner="131827681@N05" secret="8be2333be3" server="7658" farm="8" …Run Code Online (Sandbox Code Playgroud) 我有这个代码,我正在尝试返回Flickr API,但是我收到以下错误.
跨源请求已阻止:同源策略禁止读取远程资源
http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback={callback}&tags=london&tagmode=any&format=json.这可以通过将资源移动到同一域或启用CORS来解决.
如何在我的代码中启用它?
enter
MyFeed.prototype.getFeed = function(data) {
console.log(f.feedUrl);
var request = new XMLHttpRequest();
request.open('GET', f.feedUrl, true);
request.onload = function () {
if (request.status >= 200 && request.status < 400) {
// Success!
console.log(request.responseText);
var data = JSON.parse(request.responseText);
} else {
// We reached our target server, but it returned an error
console.log("error");
}
};
request.onerror = function () {
// There was a connection error of some sort
};
request.send();
}here
Run Code Online (Sandbox Code Playgroud) 通过阅读Flickr API文档,它一直声明我需要一个API密钥来使用他们的REST协议.我只是在构建一个照片查看器,收集来自Flickr的公共照片提要的信息(例如,我不打算编写上传脚本,需要API密钥).获得密钥可以获得任何附加功能吗?
更新我回答了以下问题
我试图在我的PHP代码中解码从flickr返回的json字符串.我使用CURL但它仍然返回一个字符串,即使我在json sring变量周围包装json_decode().有任何想法吗?
$api_key = '####';
$photoset_id = '###';
$query = 'http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key='.$api_key.'&photoset_id='.$photoset_id.'&extras=url_o,url_t&format=json&jsoncallback=1';
$ch = curl_init(); // open curl session
// set curl options
curl_setopt($ch, CURLOPT_URL, $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch); // execute curl session
curl_close($ch); // close curl session
var_dump(json_decode($data));
Run Code Online (Sandbox Code Playgroud) 我使用flickr照片搜索方法来检索公共照片.当我用jquery运行它,它工作正常,我得到正确形式的json对象.
{
"photos": {
"photo": [
{
.........
}
]
},
"stat": "ok"
}
Run Code Online (Sandbox Code Playgroud)
但是当我将它与AngularJs一起使用时,我得到了带有前缀jsonFlickrApi的相同对象
jsonFlickrApi({
"photos": {
"photo": [
{
......
}
]
},
"stat": "ok"
})
Run Code Online (Sandbox Code Playgroud)
我在AngularJs中使用的是:
myApp.service('dataService', function($http) {
delete $http.defaults.headers.common['X-Requested-With'];
this.flickrPhotoSearch = function() {
return $http({
method: 'GET',
url: 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=3f807259749363aaa29c2fa93945&tags=india&format=json&callback=?',
dataType: 'json'
});
}
});
Run Code Online (Sandbox Code Playgroud)
请告诉我如何将第二个JSON转换为第一个JSON.我可以在$http调用中做什么或者必须改变JSON对象.
我正在使用Web客户端类从Internet下载文件(实际上是Flickr).只要我使用这个就可以正常工作:WebClient().DownloadData(string) 但是这会锁定UI,因为它不是异步的.
但是,当我尝试时WebClient().DownloadDatAsync(string),我得到一个编译错误:"无法将System.String转换为System.Uri".
字符串MediumUrl返回 "http://farm4.static.flickr.com/2232/2232/someimage.jpg"
所以问题是如何将字符串转换"http://farm4.static.flickr.com/2232/2232/someimage.jpg"为Uri.
我尝试过的事情 -
我试过了Uri myuri = new uri(string)- 如上所述的错误.
foreach (Photo photo in allphotos)
{
//Console.WriteLine(String.Format("photo title is :{0}", photo.Title));
objimage = new MemoryStream(wc.DownloadData(photo.MediumUrl));
images.Add(new Pictures(new Bitmap(objimage), photo.MediumUrl, photo.Title));
}
Run Code Online (Sandbox Code Playgroud)