7

Я интегрировал Facebook в моем приложении и пытаюсь поделиться некоторым content.When я называю FaceBookMain(), он показывает ошибку, как: "Success БЕЗОПАСНОСТИ WARNINNG: Пожалуйста, относиться к URL выше, как вы будет ваш пароль и не будет делиться им с кем-либо. « Иногда эта ошибка возникает после входа в систему Facebook в браузере (Webview), иначе она появляется сразу после нажатия кнопки совместного доступа.URL в Facebook в BlackBerry

Самое главное здесь, я не сталкиваюсь с этой проблемой в симуляторе. Общение с Facebook работает правильно в Simulator, но не в устройстве.

Я добавляю некоторые файлы классов с ним:

Вот FacebookMain.java класс:

import net.rim.device.api.applicationcontrol.ApplicationPermissions; 
import net.rim.device.api.applicationcontrol.ApplicationPermissionsManager; 
import net.rim.device.api.system.PersistentObject; 
import net.rim.device.api.system.PersistentStore; 
import net.rim.device.api.ui.UiApplication; 

public class FacebookMain implements ActionListener{// extends MainScreen implements ActionListener { 

    // Constants 

    public final static String NEXT_URL = "http://www.facebook.com/connect/login_success.html"; 
    public final static String APPLICATION_ID = "406758776102494";//"533918076671162" ; 
    private final static long persistentObjectId = 0x854d1b7fa43e3577L; 

    static final String ACTION_ENTER = "updateStatus"; 
    static final String ACTION_SUCCESS = "statusUpdated"; 
    static final String ACTION_ERROR = "error"; 
    private ActionScreen actionScreen; 

    private PersistentObject store; 

    private LoginScreen loginScreen; 
    private LogoutScreen logoutScreen; 
    private HomeScreen homeScreen; 
    private UpdateStatusScreen updateStatusScreen; 
    private RecentUpdatesScreen recentUpdatesScreen; 
    private UploadPhotoScreen uploadPhotoScreen; 
    private FriendsListScreen friendsListScreen; 
    private PokeFriendScreen pokeFriendScreen; 
    private PostWallScreen postWallScreen; 
    private SendMessageScreen sendMessageScreen; 

    private String postMessage; 

    private FacebookContext fbc; 
    public static boolean isWallPosted=false; 
    public static boolean isFacebookScreen = false; 

    public FacebookMain(String postMessge) { 
     this.postMessage= postMessge; 
     isFacebookScreen = true; 

     checkPermissions(); 

     fbc=new FacebookContext(NEXT_URL, APPLICATION_ID); 
     loginScreen = new LoginScreen(fbc,"KingdomConnect: "+postMessge); 
     loginScreen.addActionListener(this); 
     UiApplication.getUiApplication().pushScreen(loginScreen); 

    } 

    private void init() { 
     store = PersistentStore.getPersistentObject(persistentObjectId); 
     synchronized (store) { 
      if (store.getContents() == null) { 
       store.setContents(new FacebookContext(NEXT_URL, APPLICATION_ID)); 
       store.commit(); 
      } 
     } 
     fbc = (FacebookContext) store.getContents(); 
    } 

    private void checkPermissions() { 

     ApplicationPermissionsManager apm = ApplicationPermissionsManager.getInstance(); 
     ApplicationPermissions original = apm.getApplicationPermissions(); 

     if ((original.getPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION) == ApplicationPermissions.VALUE_ALLOW) && (original.getPermission(ApplicationPermissions.PERMISSION_DEVICE_SETTINGS) == ApplicationPermissions.VALUE_ALLOW) && (original.getPermission(ApplicationPermissions.PERMISSION_CROSS_APPLICATION_COMMUNICATION) == ApplicationPermissions.VALUE_ALLOW) && (original.getPermission(ApplicationPermissions.PERMISSION_INTERNET) == ApplicationPermissions.VALUE_ALLOW) && (original.getPermission(ApplicationPermissions.PERMISSION_SERVER_NETWORK) == ApplicationPermissions.VALUE_ALLOW) && (original.getPermission(ApplicationPermissions.PERMISSION_EMAIL) == ApplicationPermissions.VALUE_ALLOW)) { 
      return; 
     } 

     /*ApplicationPermissions permRequest = new ApplicationPermissions(); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_DEVICE_SETTINGS); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_CROSS_APPLICATION_COMMUNICATION); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_INTERNET); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_SERVER_NETWORK); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_EMAIL); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_INTERNET); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_AUTHENTICATOR_API); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_SERVER_NETWORK); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_WIFI);*/ 
     ApplicationPermissions permRequest = new ApplicationPermissions(); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_DEVICE_SETTINGS); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_CROSS_APPLICATION_COMMUNICATION); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_INTERNET); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_SERVER_NETWORK); 
     permRequest.addPermission(ApplicationPermissions.PERMISSION_EMAIL); 

     boolean acceptance = ApplicationPermissionsManager.getInstance().invokePermissionsRequest(permRequest); 

     if (acceptance) { 
      // User has accepted all of the permissions. 
      return; 
     } else { 
     } 
    } 

    public void saveContext(FacebookContext pfbc) { 
     synchronized (store) { 
      store.setContents(pfbc); 
      System.out.println(pfbc); 
      store.commit(); 
     } 
    } 

    public void logoutAndExit() { 
     saveContext(null); 
     logoutScreen = new LogoutScreen(fbc); 
     logoutScreen.addActionListener(this); 
    } 

    public void saveAndExit() { 
     saveContext(fbc); 
     exit(); 
    } 

    private void exit() { 
     AppenderFactory.close(); 
     System.exit(0); 
    } 

    public void onAction(Action event) {} 
} 

Это Facebook.java класс:

public class Facebook { 

     protected Logger log = Logger.getLogger(getClass()); 
     public static String API_URL = "https://graph.facebook.com"; 

     public Facebook() { 
     } 

     public static Object read(String path, String accessToken) throws FacebookException { 
      return read(path, null, accessToken); 
     } 

     public static Object read(String path, Parameters params, String accessToken) throws FacebookException { 
      Hashtable args = new Hashtable(); 
      args.put("access_token", accessToken); 
      args.put("format", "JSON"); 

      if ((params != null) && (params.getCount() > 0)) { 
       Enumeration paramNamesEnum = params.getParameterNames(); 

       while (paramNamesEnum.hasMoreElements()) { 
        String paramName = (String) paramNamesEnum.nextElement(); 
        String paramValue = params.get(paramName).getValue(); 
        args.put(paramName, paramValue); 
       } 
      } 

      try { 
       StringBuffer responseBuffer = HttpClient.getInstance().doGet(API_URL + '/' + path, args); 

       if (responseBuffer.length() == 0) { 
        throw new Exception("Empty response"); 
       } 

       return new JSONObject(new JSONTokener(responseBuffer.toString())); 

      } catch (Throwable t) { 
       t.printStackTrace(); 
       throw new FacebookException(t.getMessage()); 
      } 
     } 

     public static Object write(String path, Object object, String accessToken) throws FacebookException { 
      Hashtable data = new Hashtable(); 
      data.put("access_token", accessToken); 
      data.put("format", "JSON"); 

      try { 
       JSONObject jsonObject = (JSONObject) object; 
       Enumeration keysEnum = jsonObject.keys(); 

       while (keysEnum.hasMoreElements()) { 
        String key = (String) keysEnum.nextElement(); 
        Object val = jsonObject.get(key); 

        if (!(val instanceof JSONObject)) { 
         data.put(key, val.toString()); 
        } 
       } 

       StringBuffer responseBuffer = HttpClient.getInstance().doPost(API_URL + '/' + path, data); 

       if (responseBuffer.length() == 0) { 
        throw new FacebookException("Empty response"); 
       } 

       return new JSONObject(new JSONTokener(responseBuffer.toString())); 
      } catch (Exception e) { 
       throw new FacebookException(e.getMessage()); 
      } 
     } 

     public static Object delete(String path, String accessToken) throws FacebookException { 
      Hashtable data = new Hashtable(); 
      data.put("access_token", accessToken); 
      data.put("format", "JSON"); 
      data.put("method", "delete"); 

      try { 
       StringBuffer responseBuffer = HttpClient.getInstance().doPost(API_URL + '/' + path, data); 

       if (responseBuffer.length() == 0) { 
        throw new FacebookException("Empty response"); 
       } 

       return new JSONObject(new JSONTokener(responseBuffer.toString())); 
      } catch (Exception e) { 
       throw new FacebookException(e.getMessage()); 
      } 
     } 

    } 


And it is BrowserScreen.class: 

public class BrowserScreen extends ActionScreen { 

    // int[] preferredTransportTypes = { TransportInfo.TRANSPORT_TCP_CELLULAR, TransportInfo.TRANSPORT_WAP2, TransportInfo.TRANSPORT_BIS_B }; 
    int[] preferredTransportTypes = TransportInfo.getAvailableTransportTypes();//{ TransportInfo.TRANSPORT_BIS_B }; 
    ConnectionFactory cf; 
    BrowserFieldConfig bfc; 
    BrowserField bf; 
    String url; 

    public BrowserScreen(String pUrl) { 
     super(); 
     url = pUrl; 

     cf = new ConnectionFactory(); 
     cf.setPreferredTransportTypes(preferredTransportTypes); 

     bfc = new BrowserFieldConfig(); 
     bfc.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE); 
     bfc.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE); 
     bfc.setProperty(BrowserFieldConfig.USER_SCALABLE, Boolean.TRUE); 
     bfc.setProperty(BrowserFieldConfig.MDS_TRANSCODING_ENABLED, Boolean.FALSE); 
     bfc.setProperty(BrowserFieldConfig.NAVIGATION_MODE, BrowserFieldConfig.NAVIGATION_MODE_POINTER); 
     bfc.setProperty(BrowserFieldConfig.VIEWPORT_WIDTH, new Integer(Display.getWidth())); 
     //  bfc.setProperty(BrowserFieldConfig.CONNECTION_FACTORY, cf); 

     bf = new BrowserField(bfc); 

    } 

    public void browse() { 
     show(); 
     fetch(); 
    } 

    public void show() { 
     add(bf); 
    } 

    public void fetch() { 
     bf.requestContent(url); 
    } 

    public void hide() { 
     delete(bf); 
    } 

} 

Если любое тело имеет какие-либо подскажите или захотите еще немного связанного кода, чтобы получить его, пожалуйста, дайте мне знать.

ответ

0

не использовать безопасное соединение. использовать http вместо https.

вы можете обратиться here

же проблема представлена ​​в stackoverflow

Facebook warning

 Смежные вопросы

  • Нет связанных вопросов^_^