/ Published in: ActionScript 3

Update a user's status using the Facebook Actionscript API
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//note that the current class aka this extends FacebookSessionUtil //initial call checks to see if user has permission to update status private function postToStatus():void { var call:FacebookCall = facebook.post(new HasAppPermission(ExtendedPermissionValues.STATUS_UPDATE,userId)); call.addEventListener(FacebookEvent.COMPLETE, onStatPermission); } //if success update -> update status else -> grant permissions (opens a new window in browser) private function onStatPermission(e:FacebookEvent):void { if (e.success && (e.data as BooleanResultData).value) { publishStat(); }else { this.facebook.grantExtendedPermission(ExtendedPermissionValues.STATUS_UPDATE); } e.currentTarget.removeEventListener(FacebookEvent.COMPLETE, arguments.callee); } //sets the status to a string defined by the user// private function publishStat():void { var statcall:FacebookCall = this.facebook.post(new SetStatus(/*insert a string*/)); statcall.addEventListener(FacebookEvent.COMPLETE, onStatPublish); } //let the user know it has been published private function onStatPublish(e:FacebookEvent):void { if (e.success) { //alert user status has been published }else { trace(e.error.rawResult); } e.currentTarget.removeEventListener(FacebookEvent.COMPLETE, arguments.callee); }
Comments
