Android, как поделиться данными с Facebook Open Graph в новой SDK 3.0?
Сейчас я настроил свое приложение Open Graph на Facebook. Это было одобрено. Я пытаюсь представить мой "объекты" через параметры пакета, но мне любопытно, как я настраиваю объект параметров пакета, как показано ниже.
РЕДАКТИРОВАТЬ:
Создаю объект и действие вот так
Objects
а такжеaction
это код для обмена
void publishToWall() {
Session session = Session.getActiveSession();
if (session != null) {
Log.i("session ==>", "" +session);
// Check for publish permissions
List 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();
}
}
}
Но я не делюсь данными в моем фейсбуке
эта ошибка получаю12-10 15:26:25.710: I/MainActivity(27667): objectParams =>(#100) conflicting og:type found in path (thebigtoss:trophy) and 'properties' (thebigtoss:tropy)
в этой строке кода}if (error != null) {<br><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());
}
}
};
У любого есть идея, как поделиться этим кодом в фейсбуке opengraph.