-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathembedly.js
More file actions
71 lines (65 loc) · 1.78 KB
/
Copy pathembedly.js
File metadata and controls
71 lines (65 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//This returns a JSON object with all sorts of goodies about the URL
//EXTRACT Docs: http://embed.ly/docs/api/extract/endpoints/1/extract
//EMBED Docs: http://embed.ly/docs/api/embed/endpoints/1/oembed
//Currently only supports Extract and Embed, no more params yet.
//Thanks to Jeff Vlahos (@jvlahos), Andrew Pellett (@anrope) for a helpful blog post and Embedly
Embedly = {
extract: function(url) {
var eSuccess = false;
if(Meteor.settings.public.embedlyApiKey){
var embedlyKey = Meteor.settings.public.embedlyApiKey;
} else {
var embedlyKey = Meteor.settings.embedlyApiKey;
}
var embedlyURL = "http://api.embed.ly/1/extract?key=" + embedlyKey + "&url=" + encodeURIComponent(url);
$.ajax({
type: 'GET',
url: embedlyURL,
dataType: 'json',
data: {},
async: false,
error: function(xhr) {
console.log('Embed.ly failed to return useful data about this particular URL.', xhr);
eSuccess = false;
},
success: function(data) {
embedly = data;
eSuccess = true;
}
});
if (eSuccess) {
return embedly;
} else {
return false;
}
},
embed: function(url) {
var eSuccess = false;
if(Meteor.settings.public.embedlyApiKey){
var embedlyKey = Meteor.settings.public.embedlyApiKey;
} else {
var embedlyKey = Meteor.settings.embedlyApiKey;
}
var embedlyURL = "http://api.embed.ly/1/oembed?key=" + embedlyKey + "&url=" + encodeURIComponent(url);
$.ajax({
type: 'GET',
url: embedlyURL,
dataType: 'json',
data: {},
async: false,
error: function(xhr) {
console.log('Embed.ly failed to return useful data about this particular URL.', xhr);
eSuccess = false;
},
success: function(data) {
embedly = data;
eSuccess = true;
}
});
if (eSuccess) {
return embedly;
} else {
return false;
}
}
}