本文整理汇总了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;
}