Android como compartilhar dados com o Facebook Open Graph no novo SDK 3.0?
Agora eu configurei meu aplicativo Open Graph no Facebook. Foi aprovado. Estou tentando enviar meus "objetos" por meio dos parâmetros do pacote, mas estou curioso para saber como configurar um objeto de pacote como o seguinte.
EDITAR:
Estou criando objeto e ação como este
Objects
eaction
este é o código para compartilhar
void publishToWall() {
Session session = Session.getActiveSession();
if (session != null) {
Log.i("session ==>", "" +session);
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
Log.i("session permissions ==>", "publishToWall");
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
try {
RequestBatch requestBatch = new RequestBatch();
Log.i("session requestBatch ==>", "requestBatch");
JSONObject tropy = new JSONObject();
tropy.put("type", "thebigtoss:tropy");
tropy.put("title", "A Game of Thrones");
tropy.put("url","http://www.thebigtoss.com/assets/app-icon.png");
tropy.put("description", "supernatural forces are mustering.");
// Set up object request parameters
Bundle objectParams = new Bundle();
objectParams.putString("object", tropy.toString());
// Set up the object request callback
Request.Callback objectCallback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
Log.i("objectParams onCompleted ==>", "onCompleted");
// Log any response error
FacebookRequestError error = response.getError();
if (error != null) {
Log.i(TAG, "objectParams =>" +error.getErrorMessage());
}
}
};
// Create the request for object creation
Request objectRequest = new Request(session,
"me/objects/thebigtoss:trophy", objectParams, HttpMethod.POST, objectCallback);
// Set the batch name so you can refer to the result
// in the follow-on publish action request
// objectRequest.setBatchEntryName("objectCreate");
// Add the request to the batch
requestBatch.add(objectRequest);
Bundle actionParams = new Bundle();
// Refer to the "id" in the result from the previous batch request
actionParams.putString("trophy", "Action parametery");
// Turn on the explicit share flag
actionParams.putString("fb:explicitly_shared", "true");
// Set up the action request callback
Request.Callback actionCallback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
// dismissProgressDialog();
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(MainActivity.this.getApplicationContext(),error.getErrorMessage(),Toast.LENGTH_LONG).show();
} else {
String actionId = null;
try {
JSONObject graphResponse = response.getGraphObject().getInnerJSONObject();
actionId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i(TAG, "JSON error "+ e.getMessage());
}
Toast.makeText(MainActivity.this.getApplicationContext(),actionId, Toast.LENGTH_LONG).show();
}
}
};
// Create the publish action request
Request actionRequest = new Request(session,
"me/thebigtoss:win", actionParams, HttpMethod.POST, actionCallback);
// Add the request to the batch
requestBatch.add(actionRequest);
// Execute the batch request
requestBatch.executeAsync();
} catch (JSONException e) {
//Auto-generated catch block
e.printStackTrace();
}
}
}
Mas não estou conseguindo compartilhar dados no meu facebook
esse erro estou ficando12-10 15:26:25.710: I/MainActivity(27667): objectParams =>(#100) conflicting og:type found in path (thebigtoss:trophy) and 'properties' (thebigtoss:tropy)
nesta linha de código deif (error != null) {<br>Log.i(TAG, "objectParams =>" +error.getErrorMessage());
}
Request.Callback objectCallback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
Log.i("objectParams onCompleted ==>", "onCompleted");
// Log any response error
FacebookRequestError error = response.getError();
if (error != null) {
Log.i(TAG, "objectParams =>" +error.getErrorMessage());
}
}
};
Qualquer um tem idéia de como compartilhar usando este código no facebook opengraph.