facebook binding added by andyjpb on Wed Jul 31 15:44:31 2013

(module facebook-lolevel
	(facebook
	  make-facebook-app
	  graph-get
	  graph-post
	  graph-delete
	  graph-delete-like
	  graph-search-general
	  graph-search-place
	  graph-search-location
	  graph-search-checkin
	  extend-facebook-token)

(import chicken scheme srfi-1 srfi-13 data-structures)

(use rest-bind oauth-client intarweb uri-common medea)

(form-urlencoded-separator "&")

; Definition of the facebook OAuth service.
(define (facebook scope) (make-oauth-service-provider
							protocol-version: 2.0
							signature-method: 'plaintext
							owner-auth-url: "https://www.facebook.com/dialog/oauth"
							token-request-url: "https://graph.facebook.com/oauth/access_token"
							token-request-method: 'GET
							scope: scope
							response-reader: form-parser))


(define (make-facebook-app scope client-credential)
  (make-oauth-service service: (facebook scope) client-credential: client-credential))

; GET : https://developers.facebook.com/docs/reference/api/selecting-results/
; Description   : Obtains an object and details about it
;
;		node-id	: The ID number of what we want to get
;
;		fields : What you want to retrieve
;
;		ids	: Run on all of a comma separated list of nodes
;
;		locale : language to return results in
;
;		date_format : What format to return dates in - default is ISO 8601
;
;		with : Only accepted value is location, only returns results with
;
;		width : Sets width of returned images
;
;		height : As above, but height
;
; Returns       : Requested data and paginator
;
(define-method (graph-get node-id #!key fields ids locale date_format with width height offset limit before after until since)
			(make-request method: 'GET uri: (uri-reference "https://graph.facebook.com/"))
			#f
			read-json)

; POST : https://developers.facebook.com/docs/reference/api/publishing/
; Description   : Writes to a node
;
;		node-id	: The ID number of what we want to write to
;
;		type 	: What property of the node do you want to write to
;
;		locale : language to return results in
;
; Returns       : Status code
;
(define-method (graph-post node-id type #!key locale date_format)
	       (make-request method: 'POST uri:
    					(uri-reference "https://graph.facebook.com/"))
	       form-urlencode
	       read-json)

...