Cloud::define("getTodos",function($params,$user){
$query = new \LeanCloud\Query("Todo");
$query->equalTo("content",$params["content"]);
try {
$result = $query->find();
} catch (\LeanCloud\CloudException $sex) {
error_log($sex->getMessage());
return "对不起,没有你要查询的条件";
}
foreach ($result as $resulets_detail) {
return "恭喜你查询到了数据(括号内)";
}
return "恭喜你查询到了数据(括号外)";
})
以上是我在云函数中定义的代码:
下面的是我在iOS端调用的代码:在iOS端调用云函数([AVCloud callFunctionInBackground:@"在云端自定义的函数"
withParameters:nil
block:^(id object, NSError *error) {
if(error == nil){
NSLog(@"%@",object);
} else {
NSLog(@"%@",error.description);
}
}];)的时候返回的信息: Error Domain=NSURLErrorDomain Code=-1007 "too many HTTP redirects" UserInfo={NSUnderlyingError=0x154d75cc0 {Error Domain=kCFErrorDomainCFNetwork Code=-1007 "(null)"}, NSErrorFailingURLStringKey=https://api.leancloud.cn/1.1/functions/sayHello, NSErrorFailingURLKey=https://api.leancloud.cn/1.1/functions/sayHello, NSLocalizedDescription=too many HTTP redirects}