Saphya Plays with Gmail, Marvel, Astronauts API

Initially I wanted to use the Gmail API to forward messages from my portfolio site directly to my email, but as it turns out it isn’t safe to leave my computer vulnerable to that kind of information. I was directed to FormspreeGetSimpleForm, and Kontactr which were email shortcuts that made users go through a third-party service to draft an email and forward it to the right parties. This was not what I wanted to do in the end, so I looked up an alternative API which was unrelated to the initial dream of the direct email that I was going for.

https://github.com/craigprotzel/Mashups/tree/master/__HELP#openish-apis

I decided to test out the Marvel API on my Spongebob Fansite, just to see if it would work out. It didn’t either, unfortunately, because I needed a server to connect my client in order to retrieve the information I wanted. My code was as follows:

var HERO = document.getElementById(‘hero’).value;
var url = ‘https://gateway.marvel.com:443/v1/public/characters?name=’+HERO+’&apikey=’+KEY;
var ts = new Date().getTime();
var hash = crypto.createHash(‘md5’).update(ts + PRIV_KEY + KEY).digest(‘hex’);
url += “&ts=”+ts+”&hash=”+hash;
console.log(HERO);
console.log(url);
//return $.get(url);
//document.getElementById(‘hero-content’).appendChild(url);

https://dzone.com/articles/more-examples-marvel-api

Source code from: https://dzone.com/articles/more-examples-marvel-api

I had a problem with generating a timestamp and a hash for the url in order to access the information the website was ‘getting’. I think if I had a server this could have been avoided, but I didn’t realise that until later.

In conclusion, I had to resort to an API that did not require me to use the server, strictly client-side. The People In Space API is an open API so I didn’t have to jump through hoops to get it to work. Unfortunately, there wasn’t a lot it could offer since the number stands at 5.

Screenshot (429)

 

Leave a Reply