好吧,所以我正在尝试创建一个带有表单的简单HTML页面,以便使用cURL提交pushbullet请求。
到目前为止,我的HTML看起来像这样。
<html>
<head>
<title>Omran's Push Application</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<form method="post" onSubmit="window.location='index.htm" action="post.php">
<p>
<label for="login">From:</label>
<input type="text" name="title" id="login">
</p>
<p>
<label for="message">Message:</label>
<input type="text" name="body" id="password">
</p>
<p class="login-submit">
<button type="submit" class="login-button">Login</button>
</p>
</form>
</body>
</html>
以下是PHP / cURL方面的内容。
<?php
//create array of data to be posted
$post_data['title'] = $_POST['title'];
$post_data['body'] = $_POST['body'];
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
//create cURL connection
$curl_connection = curl_init('https://api.pushbullet.com/v2/pushes');
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_HTTPHEADER, ['Access-Token: TOKEN_HERE']);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$result = curl_exec($curl_connection);
curl_close($curl_connection);
?>
但是,它并没有给予。它只是在post.php上给出了一个空白页
有什么想法吗?
答案 0 :(得分:1)
试试var_dump($result);
,看看会有什么回来。我不认为你实际上输出任何东西,因此空白页