【发布时间】:2016-12-14 22:45:58
【问题描述】:
我有一个 FileMaker PHP 脚本,旨在将记录中的数据回显到我的 iOS 应用程序。我刚开始使用 FileMaker PHP API,所以在这里我有点无助。
我能够成功连接到我的 FileMaker WebServer 15 并从布局中提取我需要的一半数据。问题是无论出于何种原因,我都无法获得所需的所有数据。我尝试将 FileMaker 数据库中的数据类型更改为可能的每种不同的数据类型,甚至是计算。我试过带空格和不带空格的数据,比如让$F变量=“a123 123 asdf”,它仍然只会拉取少数字段的数据。
每当我执行一个
$layout->listValueLists();
或
$layout->listFields();
它表明我试图从中检索数据的所有字段都在布局上,但由于某种原因,PHP 脚本无法从所有字段中返回数据。
这是 PHP 脚本:
<?php
require_once('includes/php/FileMaker.php');
$fm = new FileMaker();
$fm->setProperty('database', 'xx123 Master DB');
$fm->setProperty('hostspec', '123.456.789.000');
$fm->setProperty('username', 'fmphp');
$fm->setProperty('password', 'xx123');
$username = $_POST['username'];
$password = $_POST['password'];
$q = $fm -> newFindCommand('Login_Info');
$q -> addFindCriterion('username', '=='.$username);
$q -> addFindCriterion('password', '=='.$password);
$r = $q->execute();
// This is the login portion of the script
if(empty($username) or empty($password)){
echo '{"message":"User or password field blank", "code":401}';
}elseif(FileMaker::isError($r)){
if($r->code == 401){
echo '{"message":"User not found or password incorrect", "code":401}';
}else{
echo '{"message":"Unknown Error", code:'.$r->code.'}';
}
}else{
// This happens if an account has a $username and $password that are found together.
$account = $r -> getFirstRecord();
$ID_Account = $account->getField('ID_Account');
$customername = $account->getField('Customer_Name');
$username = $account->getField('username');
$F = $account->getField('ID_Account_F');
$customername2 = $account->getField('vCustomer_Name');
$testpull = $account->getField('testpull');
$logindata = array('ID_Account' => $ID_Account, 'Customer_Name' => $customername, 'User_Name' => $username, 'F_ID' => $F, 'Customer_Name2' => $customername2, 'testpull' => $testpull);
echo json_encode($logindata);
}
?>
这是脚本返回的内容:
Response: <NSHTTPURLResponse: 0x170221ba0> { URL: http://xx123.com/testing.php } { status code: 200, headers {
Connection = "keep-alive";
"Content-Length" = 114;
"Content-Type" = "text/html";
Date = "Tue, 13 Dec 2016 17:02:55 GMT";
"MS-Author-Via" = DAV;
Server = "Sucuri/Cloudproxy";
"X-Sucuri-ID" = xx123;
} }
Data: 114 bytes
JSON: ["F_ID": act1207, "User_Name": test, "Customer_Name": , "Customer_Name2": , "testpull": , "ID_Account": 1002]
【问题讨论】: