Social Media: Difference between revisions
Jump to navigation
Jump to search
Line 20: | Line 20: | ||
= Facebook = | = Facebook = | ||
[[File:facebook.png|framed|center]] | [[File:facebook.png|framed|center]] | ||
* 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: | |||
<pre> | |||
$.getJSON("https://graph.facebook.com/" & txtId.value, "callback=?", gotResult) | |||
</pre> | |||
* $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. | |||
<pre> | |||
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 | |||
</pre> | |||
* The data returned will be a JSON object, stored in data. | |||
* This code dumps the name and value of the fields in data. | |||
= PayPal = | = PayPal = | ||
[[File:paypal1.png|framed|left]][[File:paypal2.png|framed]] | [[File:paypal1.png|framed|left]][[File:paypal2.png|framed]] |
Revision as of 16:44, 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:
$.getJSON("https://graph.facebook.com/" & txtId.value, "callback=?", gotResult)
- $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.