我创建了一个网站,可以将名片流程扫描到我的API。然后返回该数据并提交到我的网站。我希望能够将处理过的json数据显示在下拉菜单中,以便用户可以选择写入数据。我已经可以将数据发送到应用程序了。在上传到网站之前让用户编辑数据时遇到了麻烦。
if (isset($_POST["Upload"])) {
// cURL call would go here
// my tmp. file would be $_FILES['image']['tmp_name'], and
// the filename would be $_FILES['image']['name']
echo "<pre>";
print_r($_FILES);
echo "</pre>";
$target_url = 'http://bcr1.intsig.net/BCRService/BCR_VCF2?PIN=&user=rkiliwa@gmail.com&pass=SGC8R3RM73CY5YFC&json=1&lang=15&size='.$_FILES['upfile']['size'];
if (function_exists('curl_file_create')) { // php 5.6+
$cFile = curl_file_create($_FILES['upfile']['tmp_name']);
} else { //
$cFile = '@' . realpath($_FILES['upfile']['tmp_name']);
}
$post = array('file_contents'=> $cFile);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result=curl_exec ($ch);
curl_close ($ch);
$json_result = json_decode($result);
$lead['contactFirstName'] = $json_result->name[0]->item->given_name;
$lead['contactLastName'] = $json_result->name[0]->item->family_name;
$lead['contactPhone'] = $json_result->telephone[0]->item->number;
$lead['companyAddress'] = $json_result->address[0]->item->street;
$lead['contactEmail'] = $json_result->email[0]->item;
$lead['otherNotes'] = $json_result->title[0]->item;
$lead['companyName'] = $json_result->organization[0]->item->unit;
$lead['marketingChannelId'] = 5;
echo "<pre>";
print_r($json_result);
echo "</pre>";
}