12935

Apprequest of Android Facebook sdk 3.0

Question:

I am using the updated Facebook SDK V3.0 final for Android. I am trying to send app requests to facebook frineds who do not have the application. The code is:

public void fbookinvite(){ Bundle postParams = new Bundle(); postParams.putString("name", "X"); postParams.putString("message", "DOWNLOAD X."); Session session = Session.getActiveSession(); postParams.putString("access_token", session.getAccessToken()); if (session==null||session.getState().isClosed()){ System.out.println("session is null"); }else{ //meaning we are good to go. Request request = new Request(session,"/friend facebook id/apprequests", postParams, HttpMethod.POST, new Request.Callback() { @Override public void onCompleted(Response response) { System.out.println("response was: "+response.toString()); } }); Request.executeBatchAsync(request); } }

When the code runs I get one of the following from the printed response:

responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 2, errorType: OAuthException, errorMessage: (#2) Failed to create any app request}, isFromCache:false

... or:

Response: responseCode: unknown, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: null}, isFromCache:false}

I have the following permissions: publist_stream and publish_actions.

After solving the problem I'd also like to know how to add a group of recipients to the app request.

I do not want to use the Facebook dialog.

Answer1:

Try this instead:

Bundle params = new Bundle(); params.putString("message", "Learn how to make your Android apps social"); params.putString("to", "YOUR_FRIEND_UID_HERE"); WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder( this, Session.getActiveSession(), params)) .setOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(Bundle values, FacebookException error) { // your code here } }).build(); requestsDialog.show();

This is the proper way to send an app request explicitly to someone. If you do not include the to parameter, the user can choose who they want to send to.

Answer2:

Response: responseCode: unknown, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: null}, isFromCache:false}

This is a scenario usually related with running simultaneous FB requests on your own threads. I learnt the hard way to use either

Request.executeAsync()

or

RequestAsyncTask

Recommend

  • Angular SSR 'Failed to lookup view' on production (Ubuntu, Nginx)
  • D3 Arc With Chevron Shaped End
  • Pairs of Observations within Groups
  • MySQL long running query in 5.5 is very fast in 5.6
  • How To Tell If User Is At A Specific Location?
  • Combining isset and is_null fails when checking undefined object property
  • spark in python: creating an rdd by loading binary data with numpy.fromfile
  • docker + nginx + node.js + php-fpm
  • MQL4, Code layout for big EA
  • What is the difference between 'import' and 'require' in JavaScript?
  • how can i open a webpage in a webview from a fragment with buttons?
  • Facebook Comments on your website via Graph API instead of Comments plugin?
  • Working with django : Proxy setup
  • Raphael-GWT: fill image of a shape (Rect) appears offset. How to resolve this?
  • Check if a file is a specific type in C
  • Map Annotation Disclosure Indicator - Xamarin.Form
  • Custom Timeline items in Glimpse
  • How do I set the logging properties in a spring java configuration?
  • How can I filter an array of dictionaries in 'updateSearchResultsForSearchController' to s
  • Multiple canvases (pages) in Fabric.js
  • Optimization of optim() in R ( L-BFGS-B needs finite values of 'fn')
  • how to add dashed border on highcharts “area” graph for every point
  • content must have a ListView whose id attribute is 'android.R.id.list'
  • Copy and paste data from multiple workbooks to a worksheet in another Workbook
  • Find angle of point on circle
  • When to use the tag in the head and body section of a html page? [duplicate]
  • Neo4j…how to get a visual representation of my data?
  • 'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs
  • Amazon Elastick BeanStalk error: Failed to create the AWS Elastic Beanstalk application version
  • Print Longitude and Latitude in textbox Android
  • iphone image to video issue in video speed
  • Functions by reference or by variable, which to use when?
  • Background transfer download task failed when app was closed
  • Write to .csv file with PHP (Commas in Data Error)