2013-09-06 3 views
1

Я написал образец кода для отправки apprequest на facebook.Android facebook отправить заявку приложения

Вот мой код:

Facebook facebook = new Facebook(APP_ID); 
Bundle params = new Bundle(); 
params.putString("title", "Goal Machine");//name 
params.putString("message", sendInvite);//link 
params.putString("to", Constant.facebookIdBuffer.toString()); 
params.putString("data", Constant.shortAppUrlForAndroid+"\n"+Constant.shortAppUrlForIphone); 
facebook.dialog(_activity, "apprequests", params, new DialogListener() {//send 
    @Override 
    public void onComplete(Bundle values) { 
     Constant.facebookIdBuffer=null; 
     postToWall(sendInvite); 
    } 

    @Override 
    public void onFacebookError(FacebookError error) { 
     Constant.showAlertDialog("Error", "Can't send ally request!", _activity.getParent(), false); 
     Constant.facebookIdBuffer=null; 
    } 

    @Override 
    public void onError(DialogError e) { 
     Constant.showAlertDialog("Error", "Can't send ally request!", _activity.getParent(), false); 
     Constant.facebookIdBuffer=null; 
    } 

    @Override 
    public void onCancel() { 
     Constant.showAlertDialog("Error", "Can't send ally request!", _activity.getParent(), false); 
     Constant.facebookIdBuffer=null; 
    } 
}); 

Но постоянно показывая диалог об ошибке:

Пожалуйста, предложите мне, что происходит не так ..? enter image description here

ответ

0

Используйте следующий код для выполнения вашей задачи: -

Bundle params = new Bundle(); 
params.putString("to", friendId); 
params.putString("message", "I am using this app...this is an awesome app" + "\n You should try it."); 
params.putString("frictionless", "1"); 

WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(context, session, params)).setOnCompleteListener(
new OnCompleteListener() { 
    @Override 
    public void onComplete(Bundle values, FacebookException error) { 

     if (error != null) { 
      if (error instanceof FacebookOperationCanceledException) { 
       Toast.makeText(context, "Request cancelled", Toast.LENGTH_SHORT).show(); 
      } else { 
       Toast.makeText(context, "Network Error", Toast.LENGTH_SHORT).show();       } 
      } else { 
       final String requestId = values.getString("request"); 
       if (requestId != null) { 
        Toast.makeText(context, "Request sent", Toast.LENGTH_SHORT).show(); 

       final String requestId = values.getString("request"); 
       if (requestId != null) { 
        Toast.makeText(context, "Request sent: " + requestIdd, Toast.LENGTH_SHORT).show(); 
       } 
      } else { 
       Toast.makeText(context, "Request cancelled", Toast.LENGTH_SHORT).show(); 

      } 
     } 
    } 
}).build(); 

requestsDialog.show(); 
Смежные вопросы