private
void
publishStory() {
Session session = Session.getActiveSession();
if
(session !=
null
){
List<String> permissions = session.getPermissions();
if
(!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization =
true
;
Session.NewPermissionsRequest newPermissionsRequest =
new
Session
.NewPermissionsRequest(
this
, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return
;
}
Bundle postParams =
new
Bundle();
postParams.putString(
"name"
,
"옷가게"
);
postParams.putString(
"caption"
,
"-girls day-"
);
postParams.putString(
"description"
,
"걸스데이랑께"
);
Request.Callback callback=
new
Request.Callback() {
public
void
onCompleted(Response response) {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId =
null
;
try
{
postId = graphResponse.getString(
"id"
);
}
catch
(JSONException e) {
}
FacebookRequestError error = response.getError();
}
};
Request request =
new
Request(session,
"me/feed"
, postParams,
HttpMethod.POST, callback);
RequestAsyncTask task =
new
RequestAsyncTask(request);
task.execute();
}
}
private
boolean
isSubsetOf(Collection<String> subset,
Collection<String> superset) {
for
(String string : subset) {
if
(!superset.contains(string)) {
return
false
;
}
}
return
true
;
}
@Override
public
void
onActivityResult(
int
requestCode,
int
resultCode, Intent data) {
super
.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(
this
, requestCode, resultCode, data);
}