Create a Facebook App on Heroku


Published on

Heroku is ideally suited to creating applications on the Facebook platform. Indeed, as you will learn in this session, you can create a Heroku-backed Facebook app directly from within Facebook. With close to a billion users, Facebook is becoming the venue for the social enterprise's storefront. Integrate your salesforce or data and now you have a truly social enterprise application. This session will teach you how to build a Facebook application using your choice of Ruby, PHP, Java, or Node.js on Heroku, integrating with data and processes in

Presented at Cloudstock San Francisco, 2012.

Published in: Technology, Design
1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Pre-session checklist: facebook dev page, workbench, Heroku home page,
  • Show ‘Trust & Manage’ tab of Heroku website to see current number
  • Heroku makes cloud development simple
  • Create a default Facebook app in Heroku. git clone to retrieve source. Point out envvars for config, mogli for Facebook Graph API interactions.
  • Show ‘Charities’ tab in Cloudstock app in
  • Show workbench to query data
  • Copy over ‘stage 1’ source code. Point out oauth2 Ruby gem, new envvars for credentials, OAuth 2.0 log in, one line of code to pull charities from, code in index.erb to show charities. Commit, push to heroku, try running – oops!!! No values for envvars! Run script to set env vars. Try running again. Invite audience to hit app. Refresh app a few times. Explain how it’s likely a bit slow, since all traffic is being handled by a single dyno – let’s fix that right now by scaling it to 5 dynos.
  • Make a change to one of the charity’s logos then refresh to show that we do always see fresh data. Invite audience to hit app. Go to System Overview page and show API usage increasing as the page is hit.
  • Go to Herokuaddons page to point out Memcache add on.
  • AddMemcacheaddon, copy over ‘stage 2’ source code, point out use of Dalli Ruby gem for Memcache. Point out caching – charity data, plus access token/instance URL for Point out cache flush code. Go to app, show trigger, cache flush method, update remote site setting, custom setting. Push new code. Invite audience to start hitting the app and watch the API Usage meter not change. Reverse the change we made earlier in and show that charity data is updated, and API usage incremented once.
  • Our brief says we need to integrate with approvals, so our app needs access to voting data, but where do we actually store it? Ask the audience – where should we store the votes?
  • Go to addons page and show levels of HerokuPostgres service.
  • Add shared-databaseaddon. Point out DataMapper usage, voting functionality – jQuery click handler posts vote to Ruby app
  • Refresh the page a few times as the votes come in. When audience is all done, show code in FB app to return vote counts. Go to and show code to pull vote counts, initiate approval. Go to VF page and show vote counts, click button to initiate approval, show record is locked for approval.
  • Create a Facebook App on Heroku

    1. 1. Create a Facebook App on Heroku Pat Patterson @metadaddy Principal Developer Evangelist
    2. 2. Safe Harbor Statement“Safe harbor” statement under the Private Securities Litigation Reform Act of 1995: This presentation and the oral remarks thataccompany it contain forward-looking statements the achievement of which involves risks, uncertainties and assumptions. If anysuch risks or uncertainties materialize or if any of the assumptions proves incorrect, our results could differ materially from theresults expressed or implied by the forward-looking statements we make. All statements other than statements of historical factcould be deemed forward-looking, including any statements concerning new, planned or upgraded services or technologydevelopments, any projections of subscriber growth, earnings, revenues or other financial items and any statements regardingstrategies or plans of management for future operations, statements of belief and statements about future customer contracts orfuture customer use of our services.The risks and uncertainties referred to above include - but are not limited to - interruptions or delays in our service or our Webhosting; our ability to complete and successfully release new and improved versions of our on-demand platform and developmentenvironment; our new business model; problems integrating, launching or operating services based on newly acquired businessesor technologies, breach of our security measures; possible fluctuations in our operating results and rate of growth; the emergingmarket in which we operate; our relatively limited operating history; our ability to hire, retain and motivate our employees andmanage our growth; competition; our ability to continue to release and gain customer acceptance of new and improved versions ofour CRM service; unanticipated changes in our effective tax rate; fluctuations in the number of shares outstanding; the price ofsuch shares; foreign currency exchange rates and interest rates.Further information on these and other factors that could affect our financial results is included in the reports on Forms 10-K, 10-Qand 8-K and in other filings we make with the Securities and Exchange Commission from time to time, including our Form 10-K forthe fiscal year ended January 31, 2007. These documents are available on the SEC Filings section of the Investor Informationsection of our website at unreleased services or features referenced in this or other press releases or public statements are not currently available andmay not be delivered on time or at all. Customers who purchase our services should make purchase decisions based upon featuresthat are currently available., inc. assumes no obligation and does not intend to update these forward-lookingstatements, except as required by law.
    3. 3. Agenda• Brief overview of Heroku• Create a Facebook app with Heroku – Pull data from – Show some best practices – Give away some money!
    4. 4. 1,250,000+ Apps Running on Heroku
    5. 5. The Heroku Cloud Application PlatformRun AnythingForget Servers $ heroku create -s cedarDeploy Instantly $ git push heroku masterScale with EaseExtend with Add-ons
    6. 6. Heroku and Facebook: Even Simpler!
    7. 7. The Brief• Create a Facebook app to – Retrieve a list of charities from – Collect votes on charities – Restrict users to a single vote• Create a app to – Manage the list of charities – When the contest is over, initiate the approval process for a donation to the winning charity
    8. 8. Charity App Back-end• Let’s look at how employees manage charities in
    9. 9. REST API• Authenticate/authorize access via OAuth 2.0• Records in identified by URLs – /services/data/v24.0/sobjects/Charity__c/a0 0d0000002XU4r• CRUD via POST/GET/PATCH/DELETE• SOQL query interface – /services/data/v24.0/query?q=SELECT+Na me+FROM+Charity__c
    10. 10. Step 1• Let’s extend our basic Facebook app to pull charity data from
    11. 11. Efficiency• App gets charity data from on every page view – GOOD: data is timely – BAD: resource consumption, performance
    12. 12. Best Practice• Let’s use Memcache to store charity data – Facebook app loads cache from – trigger flushes cache on any change
    13. 13. Step 2• Add Memcacheaddon• Store charity data in Memcache• Configure app to flush cache on any change to charity data
    14. 14. Let’s Get Voting!• But where do we store votes?
    15. 15. HerokuPostgres• Managed SQL database• Free shared-database addon for development• Several tiers of paid service for production
    16. 16. Step 3• Store votes in Postgres• Expose vote totals via RESTful Web service• Integrate with approval process in
    17. 17. Vote• Insert Heroku app URL here!
    18. 18. Conclusion• Use Heroku for your high-volume Facebook apps• Use the REST API to integrate external apps with• Integration is straightforward, but follow best practices to get a great result!
    19. 19. Resources
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.