Social Media: Difference between revisions
Jump to navigation
Jump to search
Line 26: | Line 26: | ||
* To get a Facebook graph of a facebook account, first make the request: | * To get a Facebook graph of a facebook account, first make the request: | ||
<pre> | <pre> | ||
Function btnRetrieve_onclick() | |||
$.getJSON("https://graph.facebook.com/" & txtId.value, "callback=?", gotResult) | $.getJSON("https://graph.facebook.com/" & txtId.value, "callback=?", gotResult) | ||
</pre> | End Function</pre> | ||
* $getJSON is a wrapper for an Ajax call | * $getJSON is a wrapper for an Ajax call | ||
* We put the name of the person we want in the URL | * We put the name of the person we want in the URL |
Revision as of 16:45, 12 December 2013
- This sample shows a couple of Twitter APIs
- No code needs to be written: Twitter does all the work.
- The display to be generated is set by a Twitter Widget ID
- To create a Twitter widget, sign onto Twitter
- In the above image, the top widget is a Follow widget
- Beneath that, is a Timeline widget.
- There are many, many options to explore on Twitter's site.
- The above image is a dump of the Facebook graph.
- The complete FaceBook API is rich and complex.
- Docs are at https://developers.facebook.com/docs/reference/javascript/
- To get a Facebook graph of a facebook account, first make the request:
Function btnRetrieve_onclick() $.getJSON("https://graph.facebook.com/" & txtId.value, "callback=?", gotResult) End Function
- $getJSON is a wrapper for an Ajax call
- We put the name of the person we want in the URL
- We supply the name of the function to call on return ("gotResult").
- This is an asynchronous call: we can do other things while waiting for the result.
Function gotResult(data) txtData.value = "" If data["error"] Then txtData.value = data.error.message Else For Each item in data txtData.value = txtData.value & Eval("item") & ": " & item & vbCRLF Next End If End Function
- The data returned will be a JSON object, stored in data.
- This code dumps the name and value of the fields in data.