Response.Listener<String> responseListener1 = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse1 = new JSONObject(response);
boolean success = jsonResponse1.getBoolean("success");
if (success) {
Toast.makeText(MapActivity.this, "SUCCESS",Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MapActivity.this, "INSERTION FAILED",Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(MapActivity.this, "EXCEPTION",Toast.LENGTH_LONG).show();
}
}
};
SendBookingRequest bookingRequest = new SendBookingRequest(idd,em,Adresse_source,duree,dist, responseListener1);
RequestQueue queue1 = Volley.newRequestQueue(MapActivity.this);
queue1.add(bookingRequest);
这是我的php文件 SendBookingRequest
<?php
require("password.php");
$connect = mysqli_connect("localhost", "XXXXX", "XXXXX", "XXXXX");
$driver_id = $_POST["driver_id"];
$email = $_POST["email"];
$adresse_source = $_POST["adresse_source"];
$duree = $_POST["duree"];
$distance = $_POST["distance"];
$response = array();
$dt_obj = new DateTime($response['send_moment'], new
DateTimeZone('America/Chicago'));
$dt_obj->setTimezone(new DateTimeZone('Europe/London'));
$send_time = $dt_obj->format('Y-m-d H:i:s');
echo $send_time;
function AddRequest() {
global $connect, $driver_id, $email, $adresse_source, $duree, $distance, $send_time ;
$statement = mysqli_prepare($connect, "INSERT INTO demande (driver_id, pass_id, adresse_source, duree, distance, send_moment) VALUES (?, (SELECT user_id FROM passager WHERE email = ?),?, ?, ?, ?)");
mysqli_stmt_bind_param($statement, "issdis", $driver_id, $email, $adresse_source, $duree, $distance, $send_time);
mysqli_stmt_execute($statement);
mysqli_stmt_close($statement);
}
$response["success"] = false;
AddRequest();
$response["success"] = true;
echo json_encode($response);
?>
非常感谢任何帮助。
答案 0 :(得分:0)
我认为您需要将pip install PDfminer
行放在from cStringIO import StringIO
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
import re
def convert(fname):
pages=None
if not pages:
pagenums = set()
else:
pagenums = set(pages)
output = StringIO()
manager = PDFResourceManager()
converter = TextConverter(manager, output, laparams=LAParams())
interpreter = PDFPageInterpreter(manager, converter)
infile = file(fname, 'rb')
for page in PDFPage.get_pages(infile, pagenums):
interpreter.process_page(page)
infile.close()
converter.close()
text = output.getvalue()
output.close
print text
# write Content to .txt
text_file = open("Output_1.txt", "w")
text = re.sub("\s\s+", " ", text)
text_file.write("%s" % text)
text_file.close()
convert("xyz.pdf")
上面的PHP代码