Return to Snippet

Revision: 14978
at June 19, 2009 00:17 by gluecat


Initial Code
//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);
}

Initial URL

                                

Initial Description
Update a user's status using the Facebook Actionscript API

Initial Title
Facebook update user status

Initial Tags
api, facebook

Initial Language
ActionScript 3