Php 调试HTTP POST
我正在尝试使用HTTPPOST请求执行一个PHP脚本。这是我使用的Android代码 为了执行POSTPhp 调试HTTP POST,php,android,http,post,mailto,Php,Android,Http,Post,Mailto,我正在尝试使用HTTPPOST请求执行一个PHP脚本。这是我使用的Android代码 为了执行POST String url = "xxx"; HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); // set params List<NameValuePair> pairs = new Array
String url = "xxx";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
// set params
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("toEmail", toEmail));
pairs.add(new BasicNameValuePair("toName", toName));
pairs.add(new BasicNameValuePair("fromEmail", email));
pairs.add(new BasicNameValuePair("fromName", achternaam));
pairs.add(new BasicNameValuePair("type", "Manual"));
pairs.add(new BasicNameValuePair("job", jobId));
pairs.add(new BasicNameValuePair("firstname", voornaam));
pairs.add(new BasicNameValuePair("lastname", achternaam));
pairs.add(new BasicNameValuePair("phone", tel));
pairs.add(new BasicNameValuePair("email", email));
pairs.add(new BasicNameValuePair("comment", opmerkingen));
HttpResponse response;
post.setEntity(new UrlEncodedFormEntity(pairs));
response = client.execute(post);
String url=“xxx”;
HttpClient=new DefaultHttpClient();
HttpPost=新的HttpPost(url);
//设置参数
列表对=新的ArrayList();
添加(新的BasicNameValuePair(“toEmail”,toEmail));
添加(新的BasicNameValuePair(“toName”,toName));
添加(新的BasicNameValuePair(“fromEmail”,email));
添加(新的BasicNameValuePair(“fromName”,achternaam));
添加(新的BasicNameValuePair(“类型”、“手动”));
添加(新的BasicNameValuePair(“作业”,jobId));
添加(新的BasicNameValuePair(“firstname”,voornaam));
添加(新的BasicNameValuePair(“lastname”,achternaam));
添加(新的BasicNameValuePair(“电话”),电话);
添加(新的BasicNameValuePair(“电子邮件”,email));
添加(新的BasicNameValuePair(“注释”,opmerkingen));
HttpResponse响应;
setEntity(新的UrlEncodedFormEntity(对));
响应=client.execute(post);
当我调试这段代码并进入响应本身时,BasicStatus行是:HTTP/1.1200OK。哪个应该
指示PHP脚本已正确执行,对吗?嗯,这个脚本应该做一个mailto。这是PHP脚本:
<?php
require_once('mail.php');
require_once('Job.php');
if (isset($_POST['toEmail'])) {
sql_insert(array('content' => var_export($_POST, true), 'email' =>
$_POST['toEmail'], 'type' => $_POST['type']), 'Apply');
} else {
sql_insert(array('content' => var_export($_POST, true), 'email' => 'no email',
'type' => $_POST['type']), 'Apply');
}
if (isset($_POST['type']) && $_POST['type'] == 'LinkedIn' && isset($_POST['job'])) {
$to = 'HARDCODEDEMAIL'
$from = array('email' => '', 'name' => '');
$firstname = '';
$lastname = '';
$profile = '';
$img = '';
$headline = '';
$location = '';
$industry = '';
$current = array();
$past = array();
$education = array();
$recommendations = 0;
$phone = '';
$address = '';
$twitter = array();
if (isset($_POST['toEmail'])) {
$to['email'] = $_POST['toEmail'];
}
if (isset($_POST['toName'])) {
$to['name'] = $_POST['toName'];
}
if (isset($_POST['fromEmail'])) {
$from['email'] = $_POST['fromEmail'];
}
if (isset($_POST['fromName'])) {
$from['name'] = $_POST['fromName'];
}
$job = new Job();
$job->init($_POST['job']);
if (isset($_POST['firstname'])) {
$firstname = $_POST['firstname'];
}
if (isset($_POST['lastname'])) {
$lastname = $_POST['lastname'];
}
if (isset($_POST['profile'])) {
$profile = $_POST['profile'];
}
if (isset($_POST['img'])) {
$img = $_POST['img'];
}
if (isset($_POST['headline'])) {
$headline = $_POST['headline'];
}
if (isset($_POST['location'])) {
$location = $_POST['location'];
}
if (isset($_POST['industry'])) {
$industry = $_POST['industry'];
}
if (isset($_POST['current'])) {
$currentString = $_POST['current'];
$positions = explode("*_*", $currentString);
foreach ($positions as $positionString) {
$items = explode("**", $positionString);
if (count($items) > 0) {
$position = array('title' => '', 'url' => '', 'company' => '');
$position['title'] = $items[0];
if (count($items) > 1) {
$position['company'] = $items[1];
if (count($items) > 2) {
$position['url'] = 'http://www.linkedin.com/company/' . $items[2];
}
}
$current[] = $position;
}
}
}
if (isset($_POST['past'])) {
$pastString = $_POST['past'];
$positions = explode("*_*", $pastString);
foreach ($positions as $positionString) {
$items = explode("**", $positionString);
if (count($items) > 0) {
$position = array('title' => '', 'url' => '', 'company' => '');
$position['title'] = $items[0];
if (count($items) > 1) {
$position['company'] = $items[1];
if (count($items) > 2) {
$position['url'] = 'http://www.linkedin.com/company/' . $items[2];
}
}
$past[] = $position;
}
}
}
if (isset($_POST['education'])) {
$educationsString = $_POST['education'];
$educations = explode("*_*", $educationsString);
foreach ($educations as $edu) {
$education[] = $edu;
}
}
if (isset($_POST['recommendations'])) {
$recommendations = $_POST['recommendations'];
}
if (isset($_POST['phone'])) {
$phone = $_POST['phone'];
}
if (isset($_POST['address'])) {
$address = $_POST['address'];
}
if (isset($_POST['twitter'])) {
$twitterString = $_POST['twitter'];
$accounts = explode("*_*", $twitterString);
foreach ($accounts as $account) {
$twitter[] = $account;
}
}
$mail = new Email();
$mail->linkedIn($to, $from, $job, $firstname, $lastname, $profile, $img,
$headline, $location, $industry, $current, $past, $education, $recommendations,
$phone, $address, $twitter);
} else if (isset($_POST['type']) && $_POST['type'] == 'Manual' &&
isset($_POST['job'])) {
$to = array('email' => '', 'name' => '');
$from = array('email' => '', 'name' => '');
$firstname = '';
$lastname = '';
$phone = '';
$email = '';
$comment = '';
if (isset($_POST['toEmail'])) {
$to['email'] = $_POST['toEmail'];
}
if (isset($_POST['toName'])) {
$to['name'] = $_POST['toName'];
}
if (isset($_POST['fromEmail'])) {
$from['email'] = $_POST['fromEmail'];
}
if (isset($_POST['fromName'])) {
$from['name'] = $_POST['fromName'];
}
$job = new Job();
$job->init($_POST['job']);
if (isset($_POST['firstname'])) {
$firstname = $_POST['firstname'];
}
if (isset($_POST['lastname'])) {
$lastname = $_POST['lastname'];
}
if (isset($_POST['phone'])) {
$phone = $_POST['phone'];
}
if (isset($_POST['email'])) {
$email = $_POST['email'];
}
if (isset($_POST['comment'])) {
$comment = $_POST['comment'];
}
$mail = new Email();
var_dump($to);
$mail->normal('HARDCODEDEMAIL', $from, $job, $firstname, $lastname, $phone, $email, $comment);
您是否尝试过使用linux bash中的post参数执行curl?我现在就要尝试一下,我对这一级别的web开发不太熟悉,所以我不知道该工具的存在。Linux有必要使用它吗?我不认为OK消息意味着你的脚本运行正确,而只是文章实际发布了。如果脚本不好,你就会知道,因为它不会做你想做的事情。好吧,我试着在cURL中运行它,它在第206行说他们的$end是意外的:$mail->normal($end)timkranen@hotmail.com“,$from、$job、$firstname、$lastname、$phone、$email、$comment);因此,您的php脚本中出现了错误。