2011-05-16 27 views
8

Estoy buscando alguna documentación o código de muestra sobre cómo enviar solicitudes fql multiquery a Facebook a través de iOS SDK. Encontré algunas muestras antiguas pero no funcionan para mí. He rellenado un NSDictionary con las consultas y trato de enviar la solicitud a través de [[FBRequest requestWithDelegate:self] call:@"facebook.fql.multiquery" params:params];, como se indica en las muestras que he leído, pero aparece el error "selector no reconocido enviado a la clase" y no encuentro el método "requestWithDelegate" en FBRequest.h tampoco. ¿Está desaprobado? ¡Alguna ayuda en esto sería muy apreciada!Facebook FQL multiquery en iOS SDK

+0

¿Has consultado el SDK de IOS de Facebook? Esta biblioteca iOS de código abierto le permite integrar Facebook en su aplicación iOS, incluyendo iPhone, iPad e iPod touch. El SDK es liviano y no tiene dependencias externas. Comenzar es relativamente fácil. https://github.com/facebook/facebook-ios-sdk/ – fuzz

Respuesta

14
// Construct your FQL Query 
NSString* fql = [NSString stringWithFormat:@"SELECT uid, name, hometown_location from user where uid IN (SELECT uid2 FROM friend WHERE uid1=%lld) and hometown_location != '' ORDER BY rand() limit 4", facebookId]; 

// Create a params dictionary 
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:fql forKey:@"query"]; 

// Make the request 
[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"GET" andDelegate:self]; 

El delegado FBRequestDelegate se llamará con la respuesta. Dependiendo de sus necesidades, que va a hacer algo como:

- (void)request:(FBRequest*)request didLoad:(id)result { 
    NSLog(@"didLoad() received result: %@", result); 
} 

El objeto de facebook se crea como:

Facebook * facebook = [[Facebook alloc] initWithAppId:kAppID]; 

Más información sobre cómo configurar esta opción se puede encontrar aquí: https://developers.facebook.com/docs/guides/mobile/

Y dependiendo de su consulta FQL, necesitará permisos del usuario. Ver la lista de permisos aquí: https://developers.facebook.com/docs/authentication/permissions/

También hay una consola de prueba para FQL consulta aquí: https://developers.facebook.com/docs/reference/rest/fql.query/

Y si usted quiere hacer una Multiquery en lugar de una sola consulta, que se vería así:

NSString* fql1 = [NSString stringWithFormat: 
    @"select uid2 from friend where uid1 == %lld order by rand() limit 10", facebookId]; 
NSString* fql2 = [NSString stringWithFormat: 
    @"select uid, name from user where uid in (select uid2 from #queryID)"]; 
NSString* fql3 = [NSString stringWithFormat: 
    @"select uid, status_id, message from status where uid in (select uid from #queryName) limit 1"]; 
NSString* fql = [NSString stringWithFormat: 
    @"{\"queryID\":\"%@\",\"queryName\":\"%@\",\"queryStatus\":\"%@\"}",fql1,fql2,fql3]; 

NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"queries"]; 

[facebook call:@"fql.multiquery" params:params]; 
+1

¿Qué es queryID y queryName? ¿Puedes explicar un poquito? Gracias ... Uso la consulta múltiple como mencionas, pero devuelve nulo. – Maulik

Cuestiones relacionadas