joel
committed
on 22 Oct 04
upped version numbers to 5.1.2 and updated documentation
/tcl/facebook-api-procs.tcl (+42 -3)
364 364 } {
365 365     Returns a list of photos
366 366     http://developer.facebook.com/documentation.php?v=1.0&method=photos.get
367 367 } {
368 368     set params [list session_key $session_key format $format]
369 369     if { [exists_and_not_null subj_id] } {
370 370         lappend params "subj_id"
371 371         lappend params $subj_id
372 372     }
373 373     if { [exists_and_not_null aid] } {
374 374         lappend params "aid"
375 375         lappend params $aid
376 376     }
377 377     if { [exists_and_not_null pids] } {
378 378         lappend params "pids"
379 379         lappend params $pids
380 380     }
381 381     return [facebook_api::do_request -package_key $package_key -method "photos.get" -params $params]
382 382 }
383 383
384  
385 384 # ***************************
386 385 # Feed procs
387 386 # - procs related to publishing feeds to user's profile page
388 387 # ***************************
389 388
390  
391 389 ad_proc facebook_api::set_fbml {
392 390     -package_key
393 391     -session_key
394 392     -markup
395 393 } {
396 394     Set profile FBML
397 395 } {
398 396     return [facebook_api::do_request -package_key $package_key -method "profile.setFBML" -params [list session_key $session_key markup $markup]]
399 397 }
400 398
401 399 ad_proc facebook_api::publish_feed_story {
402 400     -package_key
403 401     -session_key
404 402     -title
405 403     -body
406 404 } {
407 405     Publish a story to user's feed
408 406 } {
409 407     return [facebook_api::do_request -package_key $package_key -method "feed.publishStoryTouser" -params [list session_key $session_key title $title body $body]]
410 408 }
 
415 413     -title
416 414     -body
417 415 } {
418 416     Publish a user action to user's feed
419 417 } {
420 418     return [facebook_api::do_request -package_key $package_key -method "feed.publishActionOfUser" -params [list session_key $session_key title $title body $body]]
421 419 }
422 420
423 421 ad_proc facebook_api::publish_templatized_action {
424 422     -package_key
425 423     -session_key
426 424     -title
427 425     -body
428 426 } {
429 427     Publish a templatized story to user's feed
430 428 } {
431 429     return [facebook_api::do_request -package_key $package_key -method "feed.publishTemplatizedAction" -params [list session_key $session_key title $title body $body]]
432 430 }
433 431
434 432 # ***************************
  433 # FQL
  434 # - procs for querying fb data via fql
  435 # ***************************
  436
  437 ad_proc facebook_api::fqlquery {
  438     -package_key
  439     -session_key
  440     -query
  441     {-format json}
  442 } {
  443     Query facebook data by using FQL
  444 } {
  445     return [facebook_api::do_request -package_key $package_key -method "fql.query" -params [list session_key $session_key format $format query $query]]
  446 }
  447
  448 # ***************************
  449 # Error Handling
  450 # - use this to verify if the facebook response_string has an error-code
  451 # - returns 0 if it does not contain an error_code
  452 # - returns the error_msg if it contains an error_code
  453 # ***************************
  454
  455 ad_proc facebook_api::check_error {
  456     -fb_response_string
  457     {-format json}
  458 } {
  459     Feed this proc a response string from a facebook request.
  460     This proc returns 0 if the response is valid.
  461     It returns the error_msg if the response_string contains an error_code
  462     NOTE: only supports json format right now
  463 } {
  464     set response_json [json::json2dict $fb_response_string]
  465     if { [lindex $response_json 0] == "error_code" } {
  466         return [lindex $response_json 3]
  467     } else {
  468         return 0
  469     }
  470 }
  471
  472 # ***************************
435 473 # Custom procs
436 474 # - we're going to add some useful features to
437 475 #  this api, e.g. scoring, caching user info
438 476 # - note some of this are not yet fully functional
439 477 # ***************************
440 478
441 479 ad_proc facebook_api::score_friends {
442 480     -friend_ids
443 481     -session_key
444 482 } {
445 483     Score friends
446 484
447 485     @return list of lists {friend1 friend2 friend_p}
448 486 } {
449 487     # do requests if they arent in the db
450 488    
451 489 }
452 490
453 491 ad_proc facebook_api::save_are_friends {
454 492     -package_key