Facebook update user status


/ Published in: ActionScript 3
Save to your folder(s)

Update a user's status using the Facebook Actionscript API


Copy this code and paste it in your HTML
  1. //note that the current class aka this extends FacebookSessionUtil
  2. //initial call checks to see if user has permission to update status
  3. private function postToStatus():void {
  4. var call:FacebookCall = facebook.post(new HasAppPermission(ExtendedPermissionValues.STATUS_UPDATE,userId));
  5. call.addEventListener(FacebookEvent.COMPLETE, onStatPermission);
  6. }
  7. //if success update -> update status else -> grant permissions (opens a new window in browser)
  8. private function onStatPermission(e:FacebookEvent):void {
  9. if (e.success && (e.data as BooleanResultData).value) {
  10. publishStat();
  11. }else {
  12. this.facebook.grantExtendedPermission(ExtendedPermissionValues.STATUS_UPDATE);
  13. }
  14. e.currentTarget.removeEventListener(FacebookEvent.COMPLETE, arguments.callee);
  15. }
  16. //sets the status to a string defined by the user//
  17. private function publishStat():void {
  18. var statcall:FacebookCall = this.facebook.post(new SetStatus(/*insert a string*/));
  19. statcall.addEventListener(FacebookEvent.COMPLETE, onStatPublish);
  20. }
  21.  
  22. //let the user know it has been published
  23. private function onStatPublish(e:FacebookEvent):void {
  24.  
  25. if (e.success) {
  26. //alert user status has been published
  27.  
  28. }else {
  29. trace(e.error.rawResult);
  30. }
  31. e.currentTarget.removeEventListener(FacebookEvent.COMPLETE, arguments.callee);
  32. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.