Windows Mobile Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Thursday, 2 February 2012

Windows Live - Basic operations

Posted on 07:44 by Unknown
Windows LIVE series:
  • Introducere
  • Web Authentication
  • Live Connect
  • Basic Operations
  • SkyDrive
Astazi o sa incepem sa vorbim despre serviciile de tip CORE care exista pe Windows Live Connect. Nu imi este foarte clar daca sa ofer exemplele in C# sau in JavaScript. Cred ca ar fi mai interesant sa prezint exemplele in JavaScript si din cand in cand o sa prezint si exemple in C#. In .NET avem o librărie, este destul de simplu, iar modul în care totul funcționează este destul de ascuns.
Înainte sa începem trebuie știut ceva foarte importat. Cand un utilizator nou accesează aplicația noastră pentru prima data, iar noi dorim sa accesam anumite servicii ca și cum am fi utilizatorul respectiv, acesta o sa trebuiască sa ne de-a dreptul ca putem sa accesam aceasta informație. In general apare un pop-up, asemănător cu cel de logare, unde userul își da acordul ca aplicația noastră sa acceseze o colecție de servicii în numele sau. In funcție de modul în care facem request-ul acest drept poate sa aibe o durata limitata sau sa fie pe veci. By default dreptul de acces la resursele unui utilizator sunt temporare.
In funcție de platforma, avem la dispoziție diferite librari prin care putem sa accesam mai ușor resursele. Pentru JavaScript avem la dispozitive o librărie cu numele WL.js, iar pentru .NET avem la dispoziție librăria Microsoft.Live. Toate apelurile se pot face și manual prin intermediul apelurilor de tip REST, dar acest lucru consuma timp și este generator de bug-uri.
Oriunde dorim sa folosim librăria WL, este nevoie ca aceasta sa fie inițializata cu id de client pe care l-am primit și url de redirect, care o sa fie apelat de către Live Connect in momentul în care un utilizator se autentifica.
In primul exemplu o sa presupunem ca dorim sa accesam datele de baza a utilizatorului împreuna cu datele de profil. Primul pas este ca utilizatorul sa se logheze:
WL.init({ client_id: {idClient}, redirect_uri: {ourRedirectUrl} });
WL.login(
{ "scope": "wl.basic" },
function (response) {
if (response.status == "connected") {
alert("Utilizator conectat");
}
else {
alert("Autentificare esuata");
}
});
Acuma ca utilizatorul este autentificat, putem sa accesam datele de baza a acestuia. Pentru acest lucru trebuie sa apelam path-ul "me" prin GET. Un obiect în format JSON o sa ne fie returnat si o sa contina toate de profil a acestuia.
WL.api(
"/me", "GET",
function (response) {
if (response.error) {
alert("A aparut o eroare.");
return;
}
// response - o sa conțină toate datele de profil
}
);

In cazul in care sunteti curiosi, iata mai jos un exemplu de răspuns:
{"id":"XXXd9f52e4XXX02X"
"name":"Vunvulea Radu"
"first_name":"Vunvulea"
"last_name":"Radu"
"link":"http://profile.live.com/cid-bb7d9f52e4fdb024/"
"birth_day":null
"birth_month":null
"birth_year":null
"gender":null
"emails":
{
"preferred":"XXX@hotmail.com"
"account":"XXX@hotmail.com"
"personal":null
"business":null
}
"addresses":
{
"personal":
{
"street":null
"street_2":null
"city":null
"state":null
"postal_code":null
"region":null
}
"business":
{
"street":null
"street_2":null
"city":null
"state":null
"postal_code":null
"region":null
}
}
"phones":
{
"personal":null
"business":null
"mobile":null
}
"locale":"ro_RO"
"updated_time":"2012-02-02T06:21:16+0000"
}
Din cate putem sa observam răspunsul este in format JSON, care se poate procesa foarte usor. Odata ce un user este logat cu SCOPE-ul "wl.basic", putem sa accesam orice informatii de baza, precum date de profil, lista de contacte. Ce imi placela acest API este faptul ca, chiar daca ai acces la contacte sau la evenimente din calendar, dreptul de adaugare pe fiecare din ele se obtine printr-un SCOPE separat, a.i. utilizatorul este protejat si stie exact ce poate sa faca o aplicatie cu contul sau.
Sa presupunem ca vrem sa facem retrive la toate evenimentele utilizatorului. In acest caz o sa avem nevoie sa ne logam folosind SCOP-ul "wl.calendars" si sa apelam path-ul "/me/events".
De menționat doua lucruri:
  • cand ne definim scope-ul putem sa avem o lista de genul "scope: "wl.basic wl.calendars"
  • resursele pe care le accesam trebuie sa fie văzute ca și o structura de foldere, organizate ierarhic
In exemplul de mai jos încărcam toate evenimentele utilizatorului:
 WL.api({
path: "/me/events",
method: "GET"
}, onResponseReceive);
function onResponseReceive(response)
{
// response contine lista de evenimente
}
In cazul in care dorim sa adaugam un eveniment este nevoie sa facem request la un nou scope "wl.events_create".
 WL.api({
path: "/me/events",
method: "POST",
body: {
name: "Iesire la bere",
description: "Iesire la bere cu Ghita",
start_time: "1/1/2012 20:00",
end_time: "1/1/2012 22:00",
location: "Cluj-Napoca",
is_all_day_event: false,
availability: "busy",
visibility: "public"
}
}, onResponseReceive);
Cand ne vine raspunsul, trebuie sa verificam doar ca proprietatea error nu conține nici o eroare.
Data următoare o sa povestim despre SkyDrive si Messenger.
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in Live Connect | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Service Bus Topic - Automatic forward messages from a subscription to a topic
    Windows Azure Service Bus Topic is a service that enables us to distribute the same messages to different consumers without having to know e...
  • CDN is not the only solution to improve the page speed - Reverse Caching Proxy
    I heard more and more often think like this: “If your website is to slow, you should use a CDN.” Great, CDN is THE solution for any kind of ...
  • Content Types - Level 6: Rich Media
    Level 6: Rich Media NOTE: This is part 7 of 7 and the conclusion of this continuing series; please see earlier posts for more background inf...
  • Patterns in Windows Azure Service Bus - Message Splitter Pattern
    In one of my post about Service Bus Topics from Windows Azure I told you that I will write about a post that describe how we can design an a...
  • E-Learning Vendors Attempt to Morph Mobile
    The sign should read: " Don't touch! Wet Paint !" I had a good chuckle today after receiving my latest emailed copy of the eLe...
  • SQL - UNION and UNION ALL
    I think that all of us used until now UNION in a SQLstatement. Using this operator we can combine the result of 2 queries. For example we wa...
  • Publishing our CellCast Widget for iPad
    The rush has been on this week as our development team worked to design a new version of our CellCast Widget specifically for Apple's up...
  • Content Types - Level 2: SMS Campaigns
    Level 2: Interactive Messaging NOTE: This is part 3 of 7 in a continuing series; please see earlier posts for more background information. L...
  • Cum sa salvezi un stream direct intr-un fisier
    Cred ca este a 2-a oara când întâlnesc aceasta cerința in decurs de câteva săptămâni. Se da un stream și o locație unde trebuie salvat, se c...
  • Content Types - Level 4: Reference
    Level 4: Reference Materials & Static Content NOTE: This is part 5 of 7 in a continuing series; please see earlier posts for more backgr...

Categories

  • .NET
  • .NET nice to have
  • #if DEBUG
  • 15 iunie 2011
  • 15 octombrie 2011
  • 2011
  • abstracta
  • action
  • adaugare
  • ajax
  • Amsterdam
  • Android
  • aplicatii
  • App Fabric
  • Apple iSlate
  • array
  • as
  • ASP.NET
  • AsReadOnly
  • Assembly comun
  • async
  • Asynchronous programming
  • asyncron
  • Autofac
  • AutoMapper
  • az
  • Azure
  • Azure AppFabric Cache
  • Azure backup solution
  • Azure Storage Explorer
  • azure. cloud
  • backup
  • BCP utility
  • bing maps v7
  • BitArray
  • BlackBerry
  • blob
  • BlobContainerPublicAccessType
  • breakpoint
  • bucuresti
  • C#
  • cache
  • CallerMemberName
  • CellCast
  • Certificate
  • CES
  • change
  • ChannelFactory
  • clasa
  • classinitialize
  • clean code
  • click event
  • close
  • Cloud
  • Cluj
  • cluj-napoca
  • Code contracts
  • code retrat
  • codecamp
  • CollectionAssert
  • Compact Edition
  • compara
  • Comparer T .Default
  • CompareTo
  • comparison
  • comunitate
  • concurs
  • Conditional attribute
  • configurare
  • connection string
  • container
  • content type
  • control
  • Convert
  • convertAll
  • convertor
  • cross platform
  • CRUD
  • css
  • custom properties
  • custom request
  • DACPAC
  • Daniel Andres
  • data sync service
  • database
  • date time
  • datetime
  • debug
  • default
  • delegate
  • dependency injection
  • deploy
  • DeploymentItem
  • design patterns
  • Dev de Amsterdam
  • development stoage
  • dictionary
  • diferente
  • digging
  • director
  • Directory.Exist
  • disable
  • dispatcher
  • dispose
  • dropdown
  • dynamic
  • EF
  • email
  • encoding
  • entity framework
  • enum
  • enumerable
  • Environment.NewLine
  • error
  • error 404
  • error handling
  • eveniment
  • event
  • ews
  • excel
  • exception
  • exchange
  • exita
  • explicit
  • export
  • extension
  • field
  • File.Exist
  • finalize
  • fire and forget
  • Fluent interface pattern
  • format
  • func
  • GC.SuppressFinalize
  • generic
  • getdirectoryname
  • globalization
  • gmail
  • hackathon
  • Hadoop
  • handle
  • HTML
  • html 5
  • Html.ActionLink
  • http://www.blogger.com/img/blank.gif
  • HttpModule
  • IComparable
  • IE
  • ienumerable
  • IIS
  • image
  • implicit
  • import
  • int
  • internationalization
  • Internet Explorer
  • interop
  • Ioc
  • IP Filter
  • iPhone
  • iQuest
  • IStructuralEquatable
  • ITCamp
  • itspark
  • java script
  • javascript
  • July 2012
  • KeyedByTypeCollection
  • KeyNotFoundException
  • Kinect SDK
  • lambda expression
  • LightSwitch Microsoft Silverlight
  • linq
  • list
  • lista
  • lista servicii
  • liste
  • Live Connect
  • Live ID
  • load
  • localization
  • lock
  • m-learning
  • MAC
  • Mango
  • map
  • mapare
  • mapare propietati
  • messagequeue
  • meta properties
  • method
  • MethodImpl
  • Metro App
  • Microsoft
  • Microsoft Sync Framework
  • mlearning
  • mlearning devices
  • Mobile Apps
  • mobile in the cloud
  • mobile learning
  • mobile services
  • Mobile Web
  • mongoDb
  • monitorizare
  • msmq
  • multitasking
  • MVC
  • MVC 3
  • MVVM
  • namespace
  • nextpartitionkey
  • nextrowkey
  • Ninject
  • nivel acces
  • no result
  • normalize
  • nosql
  • null expcetion
  • null object pattern
  • NullReferenceException
  • OAuth API
  • office
  • offline
  • Open ID
  • openhackeu2011
  • operations
  • operator
  • optimization
  • option
  • outputcache
  • OutputCacheProvider
  • override
  • paginare
  • pagination
  • path
  • persistare
  • Portable Library tool
  • Post event – CodeCamp Cluj-Napoca
  • predicate
  • predictions
  • prezentare
  • process
  • proiect
  • property
  • propietati
  • query
  • ReadOnlyCollection
  • ReadOnlyDictionary
  • referinta
  • reflection
  • remote
  • reply command
  • request
  • request response
  • resouce
  • REST
  • REST Client
  • RESTSharp
  • ronua
  • rss
  • rulare
  • salvare in fisier
  • sc
  • schimbare timp
  • select
  • select nodes
  • send
  • serializare
  • serialization
  • Server.Transfer. Resposen.Redirect
  • service bus
  • ServiceBase
  • servicecontroller
  • sesiune
  • session
  • Session_End
  • Session_Start
  • setup
  • Sibiu
  • signalR
  • Silverlight
  • sincronizare
  • Single Responsibility Principle
  • SkyDrive
  • skype
  • smartphones
  • smtp
  • Snapguide
  • sniffer
  • socket
  • solid
  • spec#
  • sql
  • Sql Azure
  • SQL CE
  • sql server 2008 RC
  • SRP
  • startuptype
  • stateful
  • stateless
  • static
  • stergere
  • store
  • store procedure
  • stream
  • string
  • string.join
  • struct
  • StructuralEqualityComparer
  • submit
  • switch
  • Symbian
  • Synchronized
  • system
  • tabele
  • table
  • techEd 2012
  • tempdata
  • test
  • testcleanup
  • testinitialize
  • testmethod
  • thread
  • timer
  • ToLower
  • tool
  • tostring
  • Total Cost Calculator
  • trace ASP.NET
  • transcoding
  • tuplu
  • tutorial
  • TWmLearning
  • type
  • unit test
  • unittest
  • UrlParameter.Optional
  • Validate
  • validation
  • verificare
  • video
  • view
  • ViewBag
  • virtual
  • visual studio
  • VM role
  • Vunvulea Radu
  • wallpaper
  • WCF
  • WebBrower
  • WebRequest
  • where clause
  • Windows
  • windows 8
  • Windows Azure
  • Windows Azure Service Management CmdLets
  • windows live messenger
  • Windows Mobile
  • Windows Phone
  • windows service
  • windows store application
  • Windows Task
  • WinRT
  • word
  • workaround
  • XBox
  • xml
  • xmlns
  • XNA
  • xpath
  • YMesseger
  • Yonder
  • Zip

Blog Archive

  • ►  2013 (139)
    • ►  November (17)
    • ►  October (12)
    • ►  September (10)
    • ►  August (7)
    • ►  July (8)
    • ►  June (15)
    • ►  May (12)
    • ►  April (17)
    • ►  March (16)
    • ►  February (9)
    • ►  January (16)
  • ▼  2012 (251)
    • ►  December (9)
    • ►  November (19)
    • ►  October (26)
    • ►  September (13)
    • ►  August (35)
    • ►  July (28)
    • ►  June (27)
    • ►  May (24)
    • ►  April (18)
    • ►  March (17)
    • ▼  February (20)
      • How NOT to use AS keyword
      • Default value and TryParse
      • Field like events and polymorphic invocation
      • The string representation of a bool
      • WCF and Silverlight - How to add custom informat...
      • Windows Live - SkyDrive
      • WCF - How to add custom information to a message h...
      • Post Event - CodeCamp la Cluj-Napoca, 18 feb. 2012
      • Debug Silverlight application - breakpoint not hit
      • DateTime.ToString() formats
      • Kinect SDK preview
      • MVC - What a view should never contain( part 2)
      • MVC - What a view should never contain( part 1)
      • Interop - release COM objects( Excel.EXE hanging)
      • Intâlnire CodeCamp la Cluj-Napoca - 18 feb. 2012
      • How to change Windows wallpaper from .NET
      • How to display simple math formulas using .NET
      • Short brief - Request-Response, Asynchron and Fire...
      • Windows Live - Basic operations
      • CRUD operation on Windows Task from .NET
    • ►  January (15)
  • ►  2011 (127)
    • ►  December (11)
    • ►  November (20)
    • ►  October (8)
    • ►  September (8)
    • ►  August (8)
    • ►  July (10)
    • ►  June (5)
    • ►  May (8)
    • ►  April (9)
    • ►  March (14)
    • ►  February (20)
    • ►  January (6)
  • ►  2010 (26)
    • ►  December (1)
    • ►  November (1)
    • ►  October (1)
    • ►  June (2)
    • ►  May (1)
    • ►  April (4)
    • ►  March (1)
    • ►  February (1)
    • ►  January (14)
Powered by Blogger.

About Me

Unknown
View my complete profile