简体   繁体   English

如何在flickr上获取照片信息?

[英]How to get photo info on flickr?

如何使用PHP获得有关照片的信息,例如作者,许可证?

You call a HTTP REST query, and load the results as a string: 您调用HTTP REST查询,并将结果作为字符串加载:

$query = "http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=" . API_KEY . "&photo_id=" . $photoid . "&format=json&nojsoncallback=1";
data = json_decode(file_get_contents($query));

echo "created by: " . data->photo->owner->username;
echo "link to photopage: " . "http://www.flickr.com/photos/" . data->photo->owner->nsid; . "/" . data->photo->id;

You do this for whatever pieces of data you need from whichever REST calls you require. 您可以通过所需的任何REST调用来处理所需的任何数据。

All of this is available via the flickr api 所有这些都可以通过flickr API获得

所有信息都可以通过Flickr API获得 ,如果您戳他们的文档,您可能会找到想要的东西。

You need to use Flickr's publically avaliable API . 您需要使用Flickr的公共可用API Sign up for an API key then have a look at this page (which gives you a basic introduction to contacting the API and parsing serialized PHP. Personally I prefer using XML with SimpleXML). 注册API密钥,然后查看此页面 (为您提供了联系API和解析序列化PHP的基本介绍。就我个人而言,我更喜欢将XML与SimpleXML结合使用)。

You may find it easier to use one of the following packages: 您可能会发现使用以下软件包之一更容易:

Consult the documentation for info on using them. 请查阅文档以获取有关使用它们的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM