本文整理匯總了PHP中HTTPRequest::post方法的典型用法代碼示例。如果您正苦於以下問題:PHP HTTPRequest::post方法的具體用法?PHP HTTPRequest::post怎麽用?PHP HTTPRequest::post使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest::post方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: submit
protected static function submit()
{
$id = $_GET['item'];
$item = Items::get_instance()->get_item($id);
if (false === $item) {
throw new Exception(_r('Invalid item ID specified', 'instapaper'));
}
$user = get_option('instapaper_user');
if (empty($user)) {
throw new Exception(sprintf(_r('Please set your username and password in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
}
if (!check_nonce('instapaper-submit', $_GET['_nonce'])) {
throw new Exception(_r('Nonces did not match. Try again.', 'instapaper'));
}
$data = array('username' => get_option('instapaper_user', ''), 'password' => get_option('instapaper_pass', ''), 'url' => $item->permalink, 'title' => apply_filters('the_title', $item->title));
$request = new HTTPRequest('', 2);
$response = $request->post("https://www.instapaper.com/api/add", array(), $data);
switch ($response->status_code) {
case 400:
throw new Exception(_r('Internal error. Please report this.', 'instapaper'));
case 403:
throw new Exception(sprintf(_r('Invalid username/password. Please check your details in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
case 500:
throw new Exception(_r('An error occurred when contacting Instapaper. Please try again later.', 'instapaper'));
}
Instapaper::page_head();
?>
<div id="message">
<h1><?php
_e('Success!');
?>
</h1>
<p class="sidenote"><?php
_e('Closing window in...', 'instapaper');
?>
</p>
<p class="sidenote" id="counter">3</p>
</div>
<script>
$(document).ready(function () {
setInterval(countdown, 1000);
});
function countdown() {
if(timer > 0) {
$('#counter').text(timer);
timer--;
}
else {
self.close();
}
}
var timer = 2;
</script>
<?php
Instapaper::page_foot();
die;
}