0 Replies Latest reply on Dec 31, 2013 3:23 AM by Mudasser

    Facebook GraphAPI_Web_1_8_1 not wokring using Adobe?

    Mudasser

      i did add the GraphAPI_Web_1_8_1 api in lib folder and then add the following code and then run the app but it never come to the handler once i click on init or click on friend list

       

      <?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.graph.Facebook;

                  import com.facebook.graph.controls.Distractor;

                  import com.facebook.graph.data.FacebookSession;

                  import com.facebook.graph.net.FacebookRequest;

                  import com.facebook.graph.utils.FacebookDataUtils;

                 

                  import com.facebook.graph.Facebook;

                  import com.facebook.graph.data.FacebookSession;

                  import com.facebook.graph.net.FacebookRequest;*/

                 

                  import com.facebook.graph.Facebook;

                  import com.facebook.graph.data.FacebookSession;

                  import com.facebook.graph.net.FacebookRequest;

                 

                 

                 

                  import mx.collections.ArrayCollection;

                  import mx.containers.ControlBar;

                  import mx.containers.Panel;

                  import mx.containers.VBox;

                  import mx.controls.Alert;

                  import mx.controls.Button;

                  import mx.controls.Label;

                  import mx.controls.Spacer;

                  import mx.controls.TextInput;

                  import mx.core.IFlexDisplayObject;

                  import mx.events.CloseEvent;

                  import mx.managers.PopUpManager;

                 

                 

                 

                 

                  protected function onApiCallFriends(response:Object, fail:Object):void

                  {

                      if (response)

                      {  

                          var friends:Array = response as Array;

                          Alert.show(friends.length.toString());

                          for (var i:int = 0; i<friends.length; i++) { Alert.show(friends[i]); }

                      }

                      else{

                          Alert.show("Failed "+fail.error.message.toString());

                      }

                  }

                 

                 

                  protected function button1_clickHandler(event:MouseEvent):void

                  {

                      // TODO Auto-generated method stub

                     

                      //Facebook.login(hhandleLogin);

                     

                     

                      /*

                      if (Facebook.getSession()==null ||

                          Facebook.getSession().uid == null)

                      {

                          Facebook.login(hhandleLogin);

                      }

                      else

                      {

                          Facebook.logout(hhandleLogin);

                      }

                      */

                  }

                 

                  protected function hhandleLogin(response:Object, fail:Object):void {

                      Alert.show("yes it comes in it");

                      if (!response)

                      {

                          Alert.show("Failed "+fail.error.message.toString());

                          return;

                     

                      }

                      button1.label =response.user.username+ 'You are logged in.';

                      button1.enabled = false;

                     

                      //loadFriends();

                  }

                 

                  protected function btnInit_clickHandler(event:MouseEvent):void

                  {

                      removeEventListener(Event.ADDED_TO_STAGE, init);

                      // TODO Auto-generated method stub

                      Facebook.init('763846766955585', hhandleLogin, null, null);

                                    

                  }

                 

                  protected function button2_clickHandler(event:MouseEvent):void

                  {

                      Alert.show("Hello");

                      // TODO Auto-generated method stub

                      var params:Object = new Object();

                      params["access_token"] = Facebook.getAuthResponse().accessToken;

                      Alert.show(params["access_token"].toString());

                      Facebook.api("me/friends",onApiCallFriends, params);   

                     

                  }

                 

              ]]>

          </fx:Script>

          <s:Button id="button1" x="26" y="65" label="Login" click="button1_clickHandler(event)"/>

          <s:Button id="btnInit" x="26" y="26" label="Init" click="btnInit_clickHandler(event)"/>

          <s:Button x="26" y="110" label="Friend List" click="button2_clickHandler(event)"/>

         

       

      </s:Application>

       

       

       

       

      Kindly help me