2012-07-14 4 views
1

사용자의 페이스 북 벽에 사용자의 위치와 함께 사진 (카메라로 찍은 사진)을 게시해야합니다. 지금은, 장소를 얻을 사진과 함께 첨부 및 사용자의 벽에 업로드 어떻게사진 iOS를 통해 자신의 벽에 업로드 사용자 위치가있는 그래프 API

object containing id and name of Page associated with this location, and a location field containing geographic information such as latitude, longitude, country, and other fields (fields will vary based on geography and availability of information) 

: 지금, 페이스 북의 사진 개체는 place라는 필드가 있습니다.

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
             resultImage, @"picture", 
             location, @"place", 
             nil]; 

     [appDelegate.facebook requestWithGraphPath:@"me/photos" 
             andParams:params 
            andHttpMethod:@"POST" 
             andDelegate:self]; 

하지만, 어떻게 내가 여기 위치 매개 변수를받을 수 있나요 : 이 사진 업로드에 대한 내 코드는? 누구든지 도와 줄 수 있습니까? 미리 감사드립니다.

답변

1

장소의 객체는 할 수 면접관이되다. 원하는 위치의 전자 책 페이지 ID는 this documentation에 따릅니다. 그래서, 여기 사진을 업로드하는 동안 사용자의 위치를 ​​얻을 수있는 방법입니다.

-(void)fbCheckForPlace:(CLLocation *)location 
{ 
    NSString *centerLocation = [[NSString alloc] initWithFormat:@"%f,%f", 
           location.coordinate.latitude, 
           location.coordinate.longitude]; 
    NSLog(@"center location is : %@",centerLocation); 
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
            @"place", @"type", 
            centerLocation, @"center", 
            @"1000", @"distance", 
            nil]; 
    [centerLocation release]; 
    [appDelegate.facebook requestWithGraphPath:@"search" andParams:params andDelegate:self]; 
} 

현재 위치는 CLLocation Manager 대리인을 호출하여 얻은 다음 위의 방법으로 전달됩니다.

다음으로이 요청이 성공하면 작업 영역 개체가 변경 가능한 배열에 삽입됩니다.

- (void)uploadPhotoWithLocation 
{ 
    NSString *placeId = [[self.listOfPlaces objectAtIndex:0] objectForKey:@"id"]; 

    params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
            self.resultImage, @"picture", 
            placeId, @"place", 
            nil]; 

    [appDelegate.facebook requestWithGraphPath:@"me/photos" 
            andParams:params 
           andHttpMethod:@"POST" 
            andDelegate:self]; 
} 

나는 가능한 체크인의 첫 번째 근처의 장소 ([self.listOfPlaces objectAtIndex:0])를 촬영했으며 이제 응용 프로그램은 성공적으로 사용자와 사진을 게시 할 수 있습니다

NSArray *resultData = [result objectForKey:@"data"]; 
     for (NSUInteger i=0; i<[resultData count] && i < 5; i++) 
     { 
      [self.listOfPlaces addObject:[resultData objectAtIndex:i]]; 
     } 

그리고 사진 업로드 방법은 해고 현재 근처의 위치.

0

FB API는 '장소': '이 위치와 관련된 페이지의 이름과 이름을 포함하는 개체 및 위도, 경도, 국가 및 기타 필드와 같은 지리 정보가 포함 된 위치 입력란 (필드는 다를 수 있음) 지리 정보의 가용성) '

1) 아이폰 OS 2)에서 위치 서비스를 시작 기반으로 현재 위치를 가지고 : 위도,

는 두 개의 데이터 위도를 사용하여 경도, 경도를

0

Shabib의 위의 대답은 훌륭합니다. (필자는 직접 논평 할 담당자가 충분하지 않습니다.) 그래도 그래프 요청이/search를 성공적으로 완료하려면 "fields"매개 변수를 지정해야합니다. 내 매개 변수 사전은 다음과 같습니다.

NSDictionary *params = @{@"type" : @"place", 
         @"center" : centerLocation, 
         @"distance" : @"500", 
         @"fields" : @"id,name"}; 
관련 문제