Advertisement
Guest User

Untitled

a guest
Sep 7th, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. {
  2. "kind": "calendar#event",
  3. "start": {
  4. "dateTime": 04/10/2012 08:00 AM
  5. },
  6. "end": {
  7. "dateTime": 04/10/2012 08:00 AM
  8. },
  9. "attendees": [
  10. {
  11. "email": "myemailaddress@gmail.com",
  12. "displayName": "My Name",
  13. "organizer": True,
  14. "self": True
  15. }
  16. ],
  17. "reminders": {
  18. "useDefault": True
  19. }
  20. }
  21.  
  22. 'Code to create JSON using Dictionary Objects and Collection Objects
  23. Dim d As New Scripting.Dictionary
  24. Dim c As New Collection
  25.  
  26. d.Add "kind", "calendar#event"
  27. d.Add "summary", "Event Title/Summary"
  28.  
  29. Dim d2(4) As New Scripting.Dictionary
  30.  
  31. d2(0).Add "dateTime", "2012-04-14T16:00:00.000-04:00"
  32. d.Add "start", d2(0)
  33.  
  34. d2(1).Add "dateTime", "2012-04-14T18:00:00.000-04:00"
  35. d.Add "end", d2(1)
  36.  
  37. 'First Attendee
  38. d2(2).Add "email", "john.doe@gmail.com"
  39. d2(2).Add "displayName", "John Doe"
  40. d2(2).Add "organizer", True
  41. d2(2).Add "self", True
  42. 'Add attendee to collection
  43. c.Add d2(2)
  44.  
  45. 'Second attendee
  46. d2(3).Add "email", "suzy.doe@gmail.com"
  47. d2(3).Add "displayName", "Suzy Doe"
  48. 'Add attendee to collection
  49. c.Add d2(3)
  50.  
  51. 'Add collection to original/primary dictionary object
  52. d.Add "attendees", c
  53.  
  54. 'Add more nested pairs to original/primary dictionary object
  55. d2(4).Add "useDefault", True
  56. d.Add "reminders", d2(4)
  57.  
  58. 'Now output the JSON/results
  59. 'This requires the VBJSON module (named just JSON, a module, not a class module)
  60. Debug.Print JSON.JSONToString(d)
  61.  
  62. {"kind":"calendar#event","summary":"Event Title/Summary","start":{"dateTime":"2012-04-14T16:00:00.000-04:00"},"end":{"dateTime":"2012-04-14T18:00:00.000-04:00"},"attendees":[{"email":"john.doe@gmail.com","displayName":"John Doe","organizer":true,"self":true},{"email":"suzy.doe@gmail.com","displayName":"Suzy Doe"}],"reminders":{"useDefault":true}}
  63.  
  64. Dim objXMLHTTP As MSXML2.ServerXMLHTTP
  65. Set objXMLHTTP = New MSXML2.ServerXMLHTTP
  66. Dim sPostData As String
  67. sPostData = JSON.JSONToString(d)
  68.  
  69. Dim sURL As String
  70. sURL = "https://www.googleapis.com/calendar/v3/calendars/{mycalendarid}/events?sendNotifications=false&fields=etag%2ChtmlLink%2Cid&pp=1&access_token={my oauth2.0 access token}"
  71.  
  72. With objXMLHTTP
  73. .Open "POST", sURL, False
  74. .setRequestHeader "Content-Type", "application/json"
  75. .Send (sPostData)
  76. End With
  77.  
  78. Debug.Print objXMLHTTP.ResponseText
  79.  
  80. Set objXMLHTTP = Nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement