Facebook - obtain location /places ID via location name

前端 未结 3 1715
囚心锁ツ
囚心锁ツ 2021-02-01 22:51

I\'m able to return a location\'s details by sending a query via the graph api with the location\'s ID, however I\'m looking to achieve the reverse - effectively find location i

3条回答
  •  死守一世寂寞
    2021-02-01 23:13

    You also can use the place sdk from facebook:

    compile group: 'com.facebook.android', name: 'facebook-places', version: '4.30.0' // For latest version, see https://developers.facebook.com/docs/android/

    and then:

    PlaceSearchRequestParams.Builder builder = new PlaceSearchRequestParams.Builder();
    
    builder.setSearchText("Cafe");
    builder.setDistance(1000); // 1,000 meter maximum distance.
    builder.setLimit(10);
    builder.addField(PlaceFields.ID);
    
    GraphRequest request = PlaceManager.newPlaceSearchRequestForLocation(builder.build());
    
    request.setCallback(new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            // Handle the response. The returned ID in JSON is the placeId.
        }
    
    request.executeAsync();
    

提交回复
热议问题