[英]programmatically checkin to facebook from android app
如何以編程方式使用Foresquare等android應用程序簽入? 問題描述得很好,我不確定facebook API是否支持它
請嘗試以下方法:
private ArrayList<String> permissions = new ArrayList<String>();
permissions.addAll(Arrays.asList("photo_upload","publish_checkins","publish_actions"));
Session session = openActiveSession(YOUR ACTIVITY NAME.this, true, new Session.StatusCallback() {
@SuppressLint("UseValueOf")
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
try {
if (getCurrentLocation() != null) {
location.put("latitude", new Double(YOUR LATITUDE));
location.put("longitude", new Double(YOUR LONGITUDE));
} else {
Toast.makeText(YOUR ACTIVITY NAME.this, getString(R.string.facebook_location_not_found), Toast.LENGTH_LONG).show();
return;
}
} catch (Exception e) {
e.printStackTrace();
}
Bundle params = new Bundle();
params.putString("place", id);
params.putString("coordinates", location.toString());
if (edtMessage.getText().toString().trim().length() > 0) {
params.putString("message", message);
}
Request.Callback callback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
Toast.makeText(YOUR ACTIVITY.this,"Checkins success, Toast.LENGTH_LONG).show();
}
};
Request request = new Request(session, "me/checkins", params, HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}
}
}, permissions);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.