Social Media

From NSB App Studio
Revision as of 16:44, 12 December 2013 by Ghenne (talk | contribs) (→‎Facebook)
Jump to navigation Jump to search

Twitter

  • 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.

Facebook

  $.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.

PayPal