GithubHelp home page GithubHelp logo

imclab / itp-py-dwd-remote-apis Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matthewepler/itp-py-dwd-remote-apis

0.0 2.0 0.0 206 KB

ITP DWD Fall 2012 - Using remote web apis demo

Home Page: http://dwdpy-remoteapi.herokuapp.com/

itp-py-dwd-remote-apis's Introduction

ITP DWD - Using Remote APIs

Download code. Open code directory in Terminal.

#1 Create virtualenv

virtualenv venv

#2 Install requirements

In your code directory run the command below to install new requirements.

. runpip

or

. venv/bin/activate
pip install -r requirements.txt

2 new libraries we're using in this example, Twilio and Requests

#3 Start server

Start server

. start

or

. venv/bin/activate
foreman start

Getting Started with Remote APIs

Foursquare API

demo /fsq

This is a demo of passing a latitude and longitude to Foursquare Venue Search to get the venues nearby.

You will need the following for the demo

Register a new application with Foursquare's developer site

Take the Client ID and Client Secret and put them inside your .env file

.env

FOURSQUARE_CLIENT_ID=XXXXXXXXXXXXXXXX
FOURSQUARE_CLIENT_SECRET=XXXXXXXXXXXX

app.py will use the environment variables to make the request to Foursquare.

IMPORTANT Heroku needs your Foursquare client information too, we need to add new config variables to your app.

In your code directory in Terminal run,

heroku config:add FOURSQUARE_CLIENT_ID=XXXXXXXXXXXXX 
heroku config:add FOURSQUARE_CLIENT_SECRET=XXXXXXXXXXXXXX

Set up Google

Get your own Google API Key here https://code.google.com/apis/console/b/0/.

Put the API Key in the Javascript, in the fsq.html template file.

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE&sensor=false"></script>

Twilio demo

demo /twilio

Getting Twilio Account

  • Register https://www.twilio.com/try-twilio.
  • Verify phone number with access code.
  • Pick a phone number.
  • Poke around all their API endpoints, make and receive calls, make and receive SMS.

When you are registered locate your your Account SID and Auth Token here,https://www.twilio.com/user/account and add them to your .env file

.env

TWILIO_ACCOUNT_SID=xxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=xxxxxxxxx
TWILIO_PHONE_NUMBER=+XXXXXXXXX

Now let's add the Twilio account variables to Heroku.

In your code directory in Terminal run,

heroku config:add TWILIO_ACCOUNT_SID=xxxxxxxxxxxxxx
heroku config:add TWILIO_AUTH_TOKEN=xxxxxxxxxxxxxx
heroku config:add TWILIO_PHONE_NUMBER=+XXXXXXXXX

Mailgun

Mailgun allows you to send email via API (you can also receive email but that's for another day).

Add Mailgun to your Heroku app

heroku addons:add mailgun:starter

This is the starter plan for Mailgun and they give you 300 msgs / day for free to use for development.

Heroku and Mailgun will give you a couple of config variables. We need to place 2 variables in our .env, one of the variables we get from our Heroku config and the other variable we need to lookup via the Heroku Mailgun console panel.

#1 Get your MAILGUN_API_KEY

heroku config --shell | grep MAILGUN_API_KEY

Put the returned line into your .env file. It will look something like...

MAILGUN_API_KEY=XXXXXXXXXXXXXXXXXXXXXXX

#2 Get your MAILGUN DOMAIN NAME

Go to your Heroku App Console https://dashboard.heroku.com/apps. Click on your app and go to the Addons section on the lower left, click on Mailgun Starter.

Inside the Mailgun control panel you will see your Email domains listed. Copy your email domain and put it inside your .env file

MAILGUN_DOMAIN=appXXXXXXX.mailgun.org

Now, we need to share this new domain with Heroku config,

heroku config:add MAILGUN_DOMAIN=app9196816.mailgun.org

You can now start your server and test the code at /mailgun.

itp-py-dwd-remote-apis's People

Contributors

johnschimmel avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.