forked from yql/yql-tables
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request yql#429 from clarle/applinks
Add YQL table for App Links index
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> | ||
<meta> | ||
<author>Clarence Leung</author> | ||
<description>YQL index for App Links metadata</description> | ||
<documentationURL>http://applinks.org/documentation/</documentationURL> | ||
<sampleQuery>SELECT url, android.url from applinks WHERE url IN ("movietickets.com", "pinterest.com")</sampleQuery> | ||
</meta> | ||
<bindings> | ||
<select itemPath="" produces="XML"> | ||
<urls> | ||
<url></url> | ||
</urls> | ||
<inputs> | ||
<key id="url" type="xs:string" paramType="variable" required="true" /> | ||
</inputs> | ||
<execute> | ||
<![CDATA[ | ||
var url = inputs['url'], | ||
platforms = ['ios', 'iphone', 'ipad', 'android', 'windows_phone', 'web'], | ||
query = y.query("select * from html where url = \"" + url | ||
+ "\" and compat = 'html5' and xpath='//meta[contains(@property, \"al:\")]'") | ||
.format('json'); | ||
var data = query.results.meta, | ||
applinks = { url: url }, | ||
output = {}, | ||
i, j; | ||
for (i = 0; i < platforms.length; i++) { | ||
var platform = platforms[i]; | ||
applinks[platform] = {}; | ||
} | ||
for (j = 0; j < data.length; j++) { | ||
var item = data[j], | ||
metadata = item.property.split(':'), | ||
itemPlatform = metadata[1], | ||
property = metadata[2]; | ||
applinks[itemPlatform][property] = item.content; | ||
} | ||
output.applinks = applinks; | ||
response.object = output; | ||
]]> | ||
</execute> | ||
</select> | ||
</bindings> | ||
</table> |