Coder Social home page Coder Social logo

facebook-template-python's Introduction

Facebook/Heroku sample app -- Python

This is a sample app showing use of the Facebook Graph API, written in Python, designed for deployment to Heroku.

Run locally

Set up a Virtualenv and install dependencies:

virtualenv --no-site-packages env/
source env/bin/activate
pip install -r requirements.txt

Create an app on Facebook and set the Website URL to http://localhost:5000/.

Copy the App ID and Secret from the Facebook app settings page into your .env:

echo FACEBOOK_APP_ID=12345 >> .env
echo FACEBOOK_SECRET=abcde >> .env

Launch the app with Foreman:

foreman start

Deploy to Heroku via Facebook integration

The easiest way to deploy is to create an app on Facebook and click Cloud Services -> Get Started, then choose Python from the dropdown. You can then git clone the resulting app from Heroku.

Deploy to Heroku directly

If you prefer to deploy yourself, push this code to a new Heroku app on the Cedar stack, then copy the App ID and Secret into your config vars:

heroku create --stack cedar
git push heroku master
heroku config:add FACEBOOK_APP_ID=12345 FACEBOOK_SECRET=abcde

Enter the URL for your Heroku app into the Website URL section of the Facebook app settings page, hen you can visit your app on the web.

facebook-template-python's People

Contributors

craigkerstiens avatar dane avatar jacinda avatar mikedory avatar mortenbagai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

facebook-template-python's Issues

SSL Connection Error

I am trying to run the app locally with foreman.

Foreman successfully send the request to facebook and gets redirected to an URL which is something like:

https://127.0.0.1:5000/?code=

This instead of showing the app locally, throws an error saying : Unable to make a secure connection to the server. This may be a problem with the server, or it may be requiring a client authentication certificate that you don't have.
Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.

My redirect URL is : http://127.0.0.1:5000/

How can i deal with error?

The template app crashes when app is in sandbox mode

app_url = 'https://graph.facebook.com/{0}'.format(FB_APP_ID)
FB_APP_NAME = json.loads(requests.get(app_url).content).get('name')

... and requests.get(app_url).content return "false" when Facebook app is in sandbox mode. And calling .get on "false" ain't good.

Question: What should the directory structure look like after creating a virtualenv?

Don't know where else to ask this. After I have used virtualenv in my app and then push it to heroku the feedback indicates that the app is running in my virtualenv on the heroku servers too. That couldn't be, right? It seems to use the same requirements.txt and such...

I'm new to both Heroku and virtualenv so I'm a bit confused. I think you could improve the README by showing what the directory structure should look like after performing the steps. And also discuss some what the execution environment in production will be.

TypeError: Incorrect padding

The vanilla example app balks for me

Might this be related to the new signed_request?
That’s what this Stack Overflow article seems to suggest

http://stackoverflow.com/questions/3302946/how-to-base64-url-decode-in-python

But I can’t really wrap my had around it.

Thanks,

Traceback (most recent call last):
  File "/app/lib/python2.7/site-packages/flask/app.py", line 1306, in __call__
    return self.wsgi_app(environ, start_response)
  File "/app/lib/python2.7/site-packages/flask/app.py", line 1294, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/app/lib/python2.7/site-packages/flask/app.py", line 1292, in wsgi_app
    response = self.full_dispatch_request()
  File "/app/lib/python2.7/site-packages/flask/app.py", line 1062, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/app/lib/python2.7/site-packages/flask/app.py", line 1060, in full_dispatch_request
    rv = self.dispatch_request()
  File "/app/lib/python2.7/site-packages/flask/app.py", line 1047, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/app/exampleapp.py", line 167, in index
    access_token = get_token()
  File "/app/exampleapp.py", line 134, in get_token
    data = json.loads(urlsafe_b64decode(str(encoded_data[1])))
  File "/usr/local/lib/python2.7/base64.py", line 112, in urlsafe_b64decode
    """
  File "/usr/local/lib/python2.7/base64.py", line 76, in b64decode
    # Transform this exception for consistency
TypeError: Incorrect padding

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.