Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Wix Code Open Platform

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Wix Code Open Platform

Shlomi Shemesh

July 25, 2018

Transcript

34 slides
  1. 3rd Party APIs Wix Code Open Platform Shlomi Shemesh Head

    of Backend Engineering WixCode [email protected] twitter@shlomishemesh linkedin/shlomish
  2. Creation without limits APIs Example 1: Weather Open your website

    to the world Example 2: Email Example 3: Payments AGENDA
  3. https://www.google.co.il/search?q=wix+code&tbm=vid Weather search is an API call - returns data

    https://api.openweathermap.org/data/2.5/weather?q=Longyearbyen, SJ&appid=febfe9f6c7229ceebdf695654890dc70&units=metric
  4. Try it yourself using the QR code API doc here:

    https://openweathermap .org/current Weather api call
  5. Weather api on your site On page ready, call the

    open weather api, extract the temperature out of the json response and set it in a textbox import { fetch } from 'wix-fetch'; $w.onReady(function () { // shlomi shemesh fetch("https://api.openweathermap.org/data/2.5/weather?q=Longyearbyen,SJ&appid=fe bfe9f6c7229ceebdf695654890dc70&units=metric") .then(response => response.json()) .then(json=> String(json.main.temp)) .then(json => $w("#temperature").text = json) });
  6. SendGrid api on your site Backend function that should be

    called on event trigger, for example form submit. import {fetch} from 'wix-fetch'; export function sendWithService(key, sender, recipient, subject, body) { const url = "https://api.sendgrid.com/api/mail.send.json"; const headers = { "Authorization": "Bearer " + key, "Content-Type": "application/x-www-form-urlencoded" }; let data = `from=${sender}&to=${recipient}&subject=${subject}&text=${body}`; console.log("in backend code, data = " + data) let request = { "method": "post", "headers": headers, "body": data }; return fetch(url, request) .then(response => { console.log("back from send grid"); response.json() }); }
  7. Demo SendGrid api call In your website https://wix-code.wixsite.com/northpole/ dragon Full

    documentation can be found here: https://support.wix.com/en/article/how- to-send-an-email-on-form-submission
  8. Demo Stripe api call In your website https://wix-code.wixsite.com/northpole/ payment Full

    documentation can be found here: https://www.wix.com/code/home/foru m/wix-tips-and-updates/example-stripe -payment-processing

More Decks by Shlomi Shemesh

Other Decks in Technology