2012-12-18 99 views
0

https://graph.facebook.com/profile-id/checkins?access_token=access_token&message=“办公室”出版签入使用Facebook的图形API

我使用上面的图形API,发布我的饲料签,我想这对我的浏览器, 我得到空数组作为响应,我还使用了图形api资源管理器中的access_token,它允许使用(publish-checkins)。

我越来越像下面

 { 
    "data": [ 

    ] 
} 
+0

要发布一个签入的响应,你必须提供一个'place_id'检入到。在这里查看Checkins Create部分:https://developers.facebook.com/docs/reference/api/user/ –

+0

我只想做一些假签入(如在办公室),如何获得地点id以及什么是使用坐标参数,如果我只是想做假签入 – user1891910

+0

检查我发布的答案。这是我如何使用FB SDK V 2x来完成的。尚未迁移到V 3.x。你将不得不调整我的代码来使用新的SDK(也许)。 –

回答

0
final JSONObject jsonobj; 

try { 

    jsonobj = new JSONObject(); 
    jsonobj.put("latitude", fetLatitude); 
    jsonobj.put("longitude", fetLongitude); 

    final String message; 
    final String name = fetPlaceName; 
    final String placeID = fetPlaceID; 

    if (edittxtMessageBox != null){ 
     message = edittxtMessageBox.getText().toString(); 
    } else { 
     message = "I am at: " + fetPlaceName + " using MyAppName"; 
    } 

    new AlertDialog.Builder(this).setTitle(R.string.check_in_title) 
     .setMessage(String.format(this.getString(R.string.check_in_at), name)) 
     .setPositiveButton(R.string.checkin, new DialogInterface.OnClickListener() { 

      @Override 
      public void onClick(DialogInterface dialog, int which) { 
       Bundle params = new Bundle(); 
       params.putString("place", placeID); 
       params.putString("message", message); 
       params.putString("coordinates", jsonobj.toString()); 
       Utility.mAsyncRunner.request("me/checkins", params, "POST", 
         new placesCheckInListener(), null); 
      } 
     }).setNegativeButton(R.string.cancel, null).show(); 
} catch (Exception e) { 
    e.printStackTrace(); 
} 
+0

k,如何获得地点id。 – user1891910

+0

@ user1891910:在我的应用程序中,当用户选择“签入”选项时,他会看到一个可供选择的地方列表。当选择时,'place_id'和'坐标'通过一个'Intent'发送到我使用上面提到的代码的活动中。你需要在这些线上做些事情。如果你想做_fake checkins_,你可以使用静态的'place_id'和'co-oridinates'。 –

+0

我必须使用我自己的名字进行登记,例如“办公室”,“健身房”,....这样的话。那么这个placeid是什么以及如何创建这些,以及为什么要使用坐标参数 – user1891910