你好,
我正在我的silverstripe网站上实现一些“短代码”。例如,我已经为Youtube,Vimeo和Soundcloud创建了一些,但我找不到添加Flickr的方法。
以下是vimeo的示例代码:
public static function Vimeo($args, $caption = null, $parser = null) {
if (empty($args['id']))
return;
$data = array();
$data['VimeoID'] = $args['id'];
$data['autoplay'] = false;
$data['caption'] = $caption ? Convert::raw2xml($caption) : false;
$data['width'] = 640;
$data['height'] = 385;
$data = array_merge($data, $args);
$template = new SSViewer('shortcode/Vimeo');
return $template->process(new ArrayData($data));
这就是我为flickr找到的:
$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
但是没有.ss文件
有人知道怎么做或已经做过吗?
感谢您的帮助!
托马斯。
答案 0 :(得分:1)
<强>您好强> 我终于找到了使用flickr短代码的解决方案 - &gt;
public static function Flickr($args, $caption = null, $parser = null) {
if (empty($args['set_id']) && empty($args['user_id']))
return;
$data = array();
$data['SET'] = $args['set_id'];
$data['USER'] = $args['user_id'];
if (!$scid = SiteConfig::current_site_config()->FlickrClientID) {
$data['KEY']= $scid = SiteConfig::current_site_config()->FlickrClientID = "id";
}
ini_set("flickr", "FLICKR");
$pics = json_decode(file_get_contents(
"http://www.flickr.com/services/rest/?method=flickr.photos.getAllContexts&api_key=".$scid."&format=json&set_id=".$args['set_id']), true);
$data['ID'] = $pics['id'];
$data = array_merge($data, $args);
$template = new SSViewer('shortcode/Flickr');
return $template->process(new ArrayData($data));
}
使用此iframe - &gt;
<div class='Flickr clearfix'>
<iframe align="center" src="http://www.flickr.com/slideShow/index.gne?user_id=$USER&set_id=$SET" frameBorder="0" width="500" height="500" scrolling="no"><br /></iframe>
</div>
如果要显示一些flickr设置图片,此解决方案可以正常工作。 希望它能帮助别人。
见到你