header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
tonio
Points:0
Posts:0

5/21/2010 3:45:07 PM

Title: flex facebook - FacebookUser.interests =''


Hey all!
Just can`t get interests:String from facebook(((
I`d try a couple of methods , but nothing (

code:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
	
	
		
		<fx:Script>
			
			<![CDATA[
			
			import com.facebook.commands.users.GetInfo;
			import com.facebook.data.users.FacebookUser;
			import com.facebook.data.users.GetInfoData;
			import com.facebook.data.users.GetInfoFieldValues;
			import com.facebook.events.FacebookEvent;
			import com.facebook.net.FacebookCall;
			import com.facebook.utils.FacebookSessionUtil;
			
			import mx.controls.Alert;
			
			
			
			//If you are external, you need to launch a browser window so that a user can log-in
			
			public var fbSession:FacebookSessionUtil;
			
			
			
			private var fbApiKey:String;
			
			private var fbSecret:String;
			
			private var fbLoaderInfo:LoaderInfo;
			
			
			
			private function fbLogin():void
			
			{
			
			fbApiKey = "KEY";
			
			fbSecret = "SECRET";
			
			fbLoaderInfo = stage.loaderInfo;
			
			
			
			//The user is going to the Log-in page
			
			fbSession = new FacebookSessionUtil( fbApiKey, fbSecret, fbLoaderInfo);
			
			fbSession.addEventListener( FacebookEvent.WAITING_FOR_LOGIN, fbWaitingForLoginHandler, false, 0, true );
			
			fbSession.addEventListener( FacebookEvent.CONNECT, fbConnectHandler, false, 0, true );
			
			fbSession.login();
			
			}
			
			
			
			private function fbWaitingForLoginHandler( e:FacebookEvent ):void
			
			{
			
			//The user has returned from the log-in page and are now clicking "OK"
			
			var alert:Alert = Alert.show( "Click Ok after you've logged in", "Logging In" );
			
			alert.addEventListener( Event.CLOSE, alertCloseHandler );
			
			}
			
			
			
			private function alertCloseHandler( e:Event ):void
			
			{
			
			//Verify that the user has logged in
			
			fbSession.validateLogin();
			
			
			
			}
			
			
			
			private function fbConnectHandler( e:FacebookEvent ):void
			
			{
			
			//Get the Information for the Logged-in user through Facebook Calls
			
			//FacebookCall is using the POST Method on the Facebook Session
			
			//new GetInfo( [Current User ID], [Field Names] )
			
			// var getInfo:GetInfo = new GetInfo( new Array( fbSession.facebook.uid ), new Array( 'name', 'pic_square', 'activities', 'interests' ) );
			
			var getInfo:GetInfo = new GetInfo( new Array( fbSession.facebook.uid), new Array( GetInfoFieldValues.ALL_VALUES ) );
			
			
			
			var fbCall:FacebookCall = fbSession.facebook.post( getInfo );
			
			fbCall.addEventListener( FacebookEvent.COMPLETE, fbGetInfoCompleteHandler, false, 0, true );
			
			}
			
			
			
			private function fbGetInfoCompleteHandler( e:FacebookEvent ):void
			
			{
			
			var getInfoData:GetInfoData = e.data as GetInfoData;
			
			var fbUser:FacebookUser = getInfoData.userCollection.getItemAt( 0 ) as FacebookUser;
			
			//Set the Image and Label to use that Data
			
			userAvatar.source = fbUser.pic_square;
			
			userName.text = fbUser.name;
			
			userActivities.text = fbUser.activities;
			
			userInterests.text = fbUser.interests;
			
			}
			
			]]>
			
		</fx:Script>
		
		<mx:Button x="10" y="10" label="Login" click="fbLogin()"/>
		
		
		
		<mx:Image x="83" y="10" width="80" height="80" id="userAvatar"/>
		
		<mx:Label x="178" y="12" text="Label" id="userName"/>
		
		
		
		<mx:Label x="178" y="52" text="Interests"/>
		
		<mx:TextArea x="178" y="69" width="449" id="userInterests"/>
		
		
		
		<mx:Label x="178" y="131" text="Activities"/>
		
		<mx:TextArea x="178" y="148" width="449" id="userActivities"/>
		
		
		
	
</s:Application>



1
Friend
Points: 710
Posts:0
5/21/2010 9:30:41 PM



you code does not seems to be having any problem , have you tried using


var getInfo:GetInfo = new GetInfo( new Array( fbSession.facebook.uid ), new Array( 'name', 'pic_square', 'activities', 'interests' ) );

2
tonio
Points: 0
Posts:0
5/22/2010 3:19:59 PM



...unfortunately its not helped(
i`d try a few variants of youre code with defined array, but...
maybe i have problems out of flex? did i have to pass any wrapper php files on server? but i dont see any links on *.php ...
ok. thanks!!!
i will try to get a result.
any ideas will be blessed! (?)(sorry 4 my english)

3
Brad
Points: 750
Posts:0
5/22/2010 7:51:40 PM



might be a silly guess, have you make sure that the user whose interests you are trying to get has filled the interests field in his facebook account. If not then there will be no data.

I used this
'name', 'pic', 'interests'

4
tonio
Points: 0
Posts:0
5/25/2010 2:18:10 AM



to Brad:
Actually not. I try to get interests from my account. And i have interests filled. But string comes empty(
Just skip this problem and work next part of the project.
When i find a solution i`ll post it.
Thanks to all of you fellas!

5
SaiKrishna
Points: 0
Posts:0
9/7/2011 9:40:45 AM



Hi, Can any one help me to how to login to facebook using flex... The above code is not working in my application. Please reply soon....


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 2+0 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions