2

アプリで使用QuickBloxしていて、テーブルiOSにデータを追加しようとしていますPlaces

QBLPlace *place = [QBLPlace place];
place.geoDataID = 34691;
place.photoID = 447;
place.title = [NSString stringWithFormat:@"%@",[aView.annotation title]];
place.address = @"London, Gadge st, 34";
place.placeDescription = @"My place description";
place.latitude = pinLocation.coordinate.latitude;
place.longitude = pinLocation.coordinate.longitude;
[QBLocation createPlace:place delegate:self];

しかし、場所を追加することはできません。以下はコンソールログです

レストリクエスト:

POST http://api.quickblox.com/places.xml
headers:{
"QB-SDK" = "iOS 1.3.1";
"Qb-Token" = c1191ff8ffbfdb79b11fba6bf2a4c054d2644de8;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"place[address]" = "London, Gadge st, 34";
"place[description]" = "My place description";
"place[geo_data_id]" = 34691;
"place[photo_id]" = 447;
"place[title]" = "The Bridge Room";
}
raw body:place[address]=London%2C%20Gadge%20st%2C%2034&place[description]=My%20place%20description&place[geo_data_id]=34691&place[photo_id]=447&place[title]=The%20Bridge%20Room
2013-01-02 10:21:14.543 Chat.Points[10229:1d903] Query QBLPlaceCreateQuery DEALLOC
2013-01-02 10:21:14.551 Chat.Points[10229:1d903] Request finished, response: 

レストレスポンス:

<QBASIHTTPRequest: 0xb40fc00>
headers:{
"Access-Control-Allow-Origin" = "*";
"Access-Control-Request-Method" = "*";
"Cache-Control" = "no-cache";
Connection = Close;
"Content-Length" = 116;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Wed, 02 Jan 2013 04:51:14 GMT";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "422 Unprocessable Entity";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 5ad6e7d628b4fbd931b7896058f012cd;
"X-Runtime" = "0.052140";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:<?xml version="1.0" encoding="UTF-8"?>
<errors type="array">
<error>No photo with such id found</error>
</errors>
4

1 に答える 1

2

場所を作成する正しい方法は次のとおりです。

QBLPlace *place = [QBLPlace place];
place.geoDataID = 34691;
place.photoID = 447;
place.title = [NSString stringWithFormat:@"%@",[aView.annotation title]];
place.address = @"London, Gadge st, 34";
place.placeDescription = @"My place description";

[QBLocation createPlace:place delegate:self];

どこ:

  • geoDataID-QBLGeoDataオブジェクトのID
  • photoID-QBCBlobオブジェクトのID

エラーは、写真付きのファイルを作成してから、それを場所に接続する必要があることを示しています。

ファイルをアップロードするには、次のコードを使用してください。

NSData *file = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Hotel47" ofType:@"png"]];

[QBContent TUploadFile:file fileName:@"Hotel47 Image" contentType:@"image/png" isPublic:YES delegate:self]; 

#pragma mark -
#pragma mark QBActionStatusDelegate

- (void)completedWithResult:(Result *)result{
    // Upload file result
    if(result.success && [result isKindOfClass:[QBCFileUploadTaskResult class]]){
        // File uploaded, do something

        QBCBlob *uploadedFile  = ((QBCFileUploadTaskResult *)result).uploadedBlob;

        NSUInteger photoID = uploadedFile.ID; // use this as photo IS for place
    }else{
        NSLog("errors=%@", result.errors);
    }
}

GeoDataを作成するには、次のコードを使用してください。

QBLGeoData *geodata = [QBLGeoData geoData];
geodata.latitude = 23.2344;
geodata.longitude = -12.23523;
geodata.status = @"Hello, world";

[QBLocation createGeoData:geodata delegate:self];

#pragma mark -
#pragma mark QBActionStatusDelegate

- (void)completedWithResult:(Result *)result{
    // Check-in result
    if(result.success && [result isKindOfClass:QBLGeoDataResult.class]){
        QBLGeoDataResult *checkinResult = (QBLGeoDataResult *)result;

        NSUInteger geoDataID = checkinResult.geoData.ID; // your geo data ID
    }else{
        NSLog(@"errors=%@", result.errors);
    }
}
于 2013-01-02T08:23:24.657 に答える