Twitter & NoSQL Integration with MVC4 Web API Sarfraz Ahmed khan Senior Developer MCPD web applications MCTS –MS SharePoint & MS Project ITILv3 User Group Speaker – Microsoft Technology Practices User Group http://meetup.com/mstpug Website: http://prosarfraz.wordpress.com Twitter: @prosarfraz Linkedin: http://pk.linkedin.com/in/proSarfraz Email: SarfrazAhmed@live.com Intro
Agenda What is NoSQL Introduction to MongoDB. Demo 1 – Connecting to MongoDB via .NET Introduction to Twitter API Demo 2- Using Twitter API via .NET What is MVC4 Introduction to Web API Demo 3 – Connecting the dots Agenda
What is No-SQL SQL = Structured NoSQL = Messy - No Tables , No Joins - No Traditional Queries - Less ACID-ity + Fault Tolerant + Distributed + Highly available - RQL + key value stores + Document store + Graph database
Introduction to MongoDB Basics C++ Language Drivers Cloud Web development Platform Documents Collections Based on documents Flexible Schema Documents with Variable Fields Any field for Any Data type Capped Collections Data Format : BSON Faster than JSON ? * Flexible schema = document fields in same collection can hold different TYPE of data.
Data Modeling Considerations Data growth & change over time Queries Normalization / de-normalization Indexes Data representation in BSON
MongoDB Document _id, which must hold a unique value. name that holds another document. This sub-document contains the fields first and last, which both hold strings. birth and death that both have date types. contribs that holds an array of strings. awards that holds an array of documents.
Why MongoDB Data vs Relations Highly optimized for retrieval / appending operations Statistical or real-time analysis of growing lists of elements such as Social Media sources
Demo 1 MongoDB Instance Connecting to MongoDB via .NET
Who was Mongo ?
Production Deployments
Social Media
Twitter API Version 1 & 1.1 (https://dev.twitter.com/docs/api/1.1) TfW – Twitter for Websites Search API - Streaming API – Data Intensive Needs REST API – Core Twitter Objects
Supported Formats XML JSON RSS Atom
Key Constructs OAuth Access Token Consumer Key Consumer Secret Callback URL ( http://myweb.com/default)
Authentication Basic Authentication
OAuth Authentication
Demo 2 Using Twitter API via .NET
MVC
Evolution Release Features MVC3 MVC2 Templated Helpers Areas Client-side Validation Child action rendering Data Annotations support More model binding Asynchronous controllers Bunch of other stuff MVC3 Razor view engine Unobtrusive client-side validation and jQuery support Dependency Injection support More Validation JSON model binding Granular request validation Requires .NET 4
MVC 4 Refreshed and modernized default project templates New mobile project template asynchronous methods Azure SDK Database Migrations Bundling & Minifications Web API.
Web API Build Richer Apps Reach more clients JQuery, JavaScript , SilverLight , Flash Devices & Platforms. RESTful
Demo 3 Creating .Net Web API Project Unit Testing Web API
Applications Social Media Analytics Sentiment Analysis
Revisiting Agenda. Using MongoDB via .Net Using Twitter API via .NET Web API