API of memory cards. I'm beginning this with people in my company.
git clone https://github.com/scottmotte/carte.git
cd carte
Then run srvdir and visit the url.
srvdir
Parklet might be where you check your employee directory. Here's how to scrape all their photos and names with js.
Visit the directory, go to the view that has the smaller pictures, load everyone, and then open Chrome console.
Paste the following in.
var results = []; var uri_pattern = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig; $item = $(".value-items .value-item"); $item.each(function() { var style = $( this ).find(".employee").attr("style"); var matches = style.match(uri_pattern); var name = $(this).find("span[name='name']").text(); if (matches) { results.push({front: "<img src='"+matches[0]+"' />", back: name, tags: ["sendgrid"] });} }); var str = JSON.stringify(results, undefined, 2); console.log(str); $("body").append(str);
Scroll to the bottom of the screen and double click the newly appended content.
Paste that json content into here.
Copy the results. Paste those results in cards.json.
The carte.herokuapp.com API is based around REST. It uses standard HTTP authentication. JSON is returned in all responses from the API, including errors.
I've tried to make it as easy to use as possible, but if you have any feedback please let me know.
To start using the carte API, you must first create a deck.
Pass an email to create your account at carte-api.herokuapp.com.
ANY https://carte-api.herokuapp.com/api/v0/accounts/create.json?&email=[email]&api_key=[api_key]
- api_key
https://carte-api.herokuapp.com/api/v0/accounts/create.json?email=[email]&api_key=[api_key]
{
"accounts": [{
"email": "test@example.com",
"api_key": "the_default_generated_api_key_that_you_should_keep_secret"
}]
}
{
errors: [{
"code": "required",
"field": "email",
"message": "email cannot be blank"
}]
}
Pass an api_key, front, and back to create your card.
ANY https://carte-api.herokuapp.com/api/v0/cards/create.json?api_key=[api_key]&front=[front]&back=[back]
- api_key
- front
- back
https://carte-api.herokuapp.com/api/v0/cards/create.json?api_key=[api_key]&front=[front]&back=[back]
{
"cards": [{
"id": "12345",
"front": "<img src='http://example.com/some-image.jpg'>",
"back": "John Doe",
}]
}
{
errors: [{
"code": "required",
"field": "front",
"message": "front cannot be blank"
}]
}