2023-03-16 17:22:22 +00:00
|
|
|
title: Flickr Demo
|
2023-01-28 23:55:02 +00:00
|
|
|
caption: Flickr
|
|
|
|
tags: $:/tags/Macro $:/tags/GeospatialDemo
|
2023-01-13 11:35:34 +00:00
|
|
|
|
2023-01-18 08:38:06 +00:00
|
|
|
<!--
|
|
|
|
Get items from a Flickr album/interestingness/collection etc.
|
|
|
|
-->
|
2023-02-10 16:34:19 +00:00
|
|
|
\procedure flickr-get-items(per_page:"100",page_number:"1",method:"flickr.photosets.getPhotos",paramName:"group_id",resultPhotoRoot:"photoset")
|
2023-01-13 11:35:34 +00:00
|
|
|
|
2023-01-18 11:27:14 +00:00
|
|
|
\procedure completion()
|
2023-01-13 11:35:34 +00:00
|
|
|
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
|
|
|
|
<$action-log msg="In completion"/>
|
|
|
|
<$action-log/>
|
|
|
|
<!-- Success -->
|
|
|
|
<$list filter="[<status>compare:number:gteq[200]compare:number:lteq[299]]" variable="ignore">
|
2023-01-18 08:38:06 +00:00
|
|
|
<$list filter="[<data>jsonindexes<resultPhotoRoot>,[photo]]" variable="photoIndex">
|
2023-01-13 11:35:34 +00:00
|
|
|
<$let
|
2023-01-18 08:38:06 +00:00
|
|
|
photoData={{{ [<data>jsonextract<resultPhotoRoot>,[photo],<photoIndex>] }}}
|
2023-01-13 11:35:34 +00:00
|
|
|
photoFarm={{{ [<photoData>jsonget[farm]] }}}
|
|
|
|
photoServer={{{ [<photoData>jsonget[server]] }}}
|
|
|
|
photoID={{{ [<photoData>jsonget[id]] }}}
|
|
|
|
photoSecret={{{ [<photoData>jsonget[secret]] }}}
|
|
|
|
>
|
|
|
|
<$action-setfield
|
|
|
|
$tiddler={{{ [<photoID>addprefix[Flickr Photo ]] }}}
|
|
|
|
tags="$:/tags/GeoMarker $:/tags/FlickrPhoto"
|
|
|
|
caption={{{ [<photoData>jsonget[title]] }}}
|
|
|
|
lat={{{ [<photoData>jsonget[latitude]] }}}
|
|
|
|
long={{{ [<photoData>jsonget[longitude]] }}}
|
|
|
|
alt="0"
|
|
|
|
photo-url={{{ [[https://farm]addsuffix<photoFarm>addsuffix[.staticflickr.com/]addsuffix<photoServer>addsuffix[/]addsuffix<photoID>addsuffix[_]addsuffix<photoSecret>addsuffix[_b.jpg]] }}}
|
|
|
|
icon-url={{{ [[https://farm]addsuffix<photoFarm>addsuffix[.staticflickr.com/]addsuffix<photoServer>addsuffix[/]addsuffix<photoID>addsuffix[_]addsuffix<photoSecret>addsuffix[_s.jpg]] }}}
|
|
|
|
/>
|
|
|
|
</$let>
|
|
|
|
</$list>
|
2023-01-18 11:55:20 +00:00
|
|
|
<$let
|
|
|
|
pages={{{ [<data>jsonget[photos],[pages]] }}}
|
|
|
|
>
|
|
|
|
<$list filter="[<page_number>compare:number:lt<pages>]" variable="ignore">
|
|
|
|
<$macrocall $name="flickr-get-items" page_page=<<per_page>> page_number={{{ [<page_number>add[1]] }}} method=<<method>> resultPhotoRoot=<<resultPhotoRoot>>/>
|
|
|
|
</$list>
|
|
|
|
</$let>
|
2023-01-13 11:35:34 +00:00
|
|
|
</$list>
|
|
|
|
\end completion
|
|
|
|
|
2023-01-18 11:27:14 +00:00
|
|
|
\procedure progress()
|
2023-01-13 11:35:34 +00:00
|
|
|
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
|
|
|
|
<$action-log message="In progress-actions"/>
|
|
|
|
\end progress
|
|
|
|
|
2023-01-18 11:27:14 +00:00
|
|
|
\procedure request-url()
|
2023-01-13 11:35:34 +00:00
|
|
|
https://api.flickr.com/services/rest/
|
|
|
|
\end request-url
|
|
|
|
|
|
|
|
<$action-sendmessage
|
|
|
|
$message="tm-http-request"
|
|
|
|
url=<<request-url>>
|
|
|
|
method="GET"
|
2023-01-18 11:27:14 +00:00
|
|
|
query-method=<<method>>
|
2023-01-13 11:35:34 +00:00
|
|
|
query-extras="geo"
|
2023-01-18 11:55:20 +00:00
|
|
|
query-per_page=<<per_page>>
|
|
|
|
query-page=<<page_number>>
|
2023-01-13 11:35:34 +00:00
|
|
|
query-format="json"
|
|
|
|
query-nojsoncallback="1"
|
2023-02-10 16:34:19 +00:00
|
|
|
$names="[<paramName>addprefix[query-]]"
|
|
|
|
$values={{$:/config/flickr-param}}
|
2023-01-13 11:35:34 +00:00
|
|
|
header-accept="application/json"
|
|
|
|
password-query-api_key="flickr-api-key"
|
|
|
|
bind-status="$:/temp/flickr/status"
|
|
|
|
bind-progress="$:/temp/flickr/progress"
|
|
|
|
oncompletion=<<completion>>
|
|
|
|
onprogress=<<progress>>
|
2023-01-18 11:55:20 +00:00
|
|
|
var-method=<<method>>
|
|
|
|
var-per_page=<<per_page>>
|
|
|
|
var-page_number=<<page_number>>
|
2023-01-18 11:27:14 +00:00
|
|
|
var-resultPhotoRoot=<<resultPhotoRoot>>
|
2023-01-13 11:35:34 +00:00
|
|
|
/>
|
|
|
|
\end
|
|
|
|
|
2023-02-10 16:34:19 +00:00
|
|
|
\procedure flickr-get-photos-of-user-items()
|
|
|
|
<$macrocall $name="flickr-get-items" method="flickr.people.getPhotosOf" paramName="user_id" resultPhotoRoot="photos"/>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure flickr-get-group-items()
|
|
|
|
<$macrocall $name="flickr-get-items" method="flickr.groups.pools.getPhotos" paramName="group_id" resultPhotoRoot="photos"/>
|
|
|
|
\end
|
|
|
|
|
2023-01-18 11:27:14 +00:00
|
|
|
\procedure flickr-get-album-items()
|
2023-02-10 16:34:19 +00:00
|
|
|
<$macrocall $name="flickr-get-items" method="flickr.photosets.getPhotos" paramName="photoset_id" resultPhotoRoot="photoset"/>
|
2023-01-18 08:38:06 +00:00
|
|
|
\end
|
|
|
|
|
2023-01-18 11:27:14 +00:00
|
|
|
\procedure flickr-get-interesting-items()
|
2023-01-18 08:38:06 +00:00
|
|
|
<$macrocall $name="flickr-get-items" method="flickr.interestingness.getList" resultPhotoRoot="photos"/>
|
|
|
|
\end
|
|
|
|
|
2023-01-28 23:55:02 +00:00
|
|
|
! Retrieve Geotagged Flickr Photos
|
2023-01-13 11:35:34 +00:00
|
|
|
|
2023-02-10 16:34:19 +00:00
|
|
|
Parameter for Flickr retrievals: <$edit-text tiddler="$:/config/flickr-param" tag="input"/>
|
|
|
|
|
2023-01-18 08:38:06 +00:00
|
|
|
<$button>
|
|
|
|
<$macrocall $name="flickr-get-album-items"/>
|
|
|
|
Get Flickr album
|
2023-02-10 16:34:19 +00:00
|
|
|
</$button> (parameter shuld be an album ID, e.g. 72157630297432522)
|
2023-01-18 08:38:06 +00:00
|
|
|
|
|
|
|
<$button>
|
|
|
|
<$macrocall $name="flickr-get-interesting-items"/>
|
|
|
|
Get Flickr interesting items
|
2023-02-10 16:34:19 +00:00
|
|
|
</$button> (no parameter needed)
|
|
|
|
|
|
|
|
<$button>
|
|
|
|
<$macrocall $name="flickr-get-photos-of-user-items"/>
|
|
|
|
Get Flickr photos of user
|
|
|
|
</$button> (parameter shuld be a user ID, e.g. 35468148136@N01)
|
|
|
|
|
|
|
|
<$button>
|
|
|
|
<$macrocall $name="flickr-get-group-items"/>
|
|
|
|
Get Flickr group
|
|
|
|
</$button> (parameter shuld be an album ID, e.g. 22075379@N00)
|