本文整理汇总了PHP中access_token函数的典型用法代码示例。如果您正苦于以下问题:PHP access_token函数的具体用法?PHP access_token怎么用?PHP access_token使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了access_token函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
/** @see WP_Widget::widget */
function widget($args, $instance)
{
extract($args);
$widget_title = $instance['widget_title'];
if (isset($instance['auto_play'])) {
$auto_play = 'true';
} else {
$auto_play = 'false';
}
$info = crInstGetInfo(user_id(), access_token());
echo $before_widget;
echo $before_title . $widget_title . $after_title;
echo '<div class="instagram-wrap">';
echo crInstShowInfo($info, array('website' => true, 'media' => true, 'followers' => true, 'following' => true, 'profile_pic' => true), $this->avatar_width);
echo crInstShowWidgetData(crInstGetSelfFeed(access_token()), $info, $this->display_photos, $this->item_width, "sIntSelfFeed", $instance['display_caption']);
echo '</div>';
?>
<script type="text/javascript">
jQuery(document).ready(function($){
$("a[data-rel^='sIntSelfFeed']").prettyPhoto({
hook: 'data-rel',
autoplay_slideshow: <?php
echo $auto_play;
?>
,
social_tools: false
});
});
</script>
<?php
echo $after_widget;
}
示例2: createMenu
function createMenu($data)
{
$access_token = access_token();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" . $access_token);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$tmpInfo = curl_exec($ch);
if (curl_errno($ch)) {
return curl_error($ch);
}
curl_close($ch);
return $tmpInfo;
}
示例3: acquire_poll
function acquire_poll($url)
{
// acquire request token and access token for future requests
$token_string = request_token();
$token_string2 = access_token($token_string);
$tokens = form_tokens($token_string, $token_string2);
// retrieve poll's 16-character id
$id = extract_id($url);
// access this poll
$poll = access_poll($id, $tokens);
// format poll data
$xml_array = parse($poll);
// store tokens for future use in submitting poll
$xml_array['tokens'] = $tokens;
return $xml_array;
}
示例4: access_token
<?php
$access_token = access_token($db);
$url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $access_token;
$query_sql = "SELECT wxid FROM " . $ecs->table('users') . " WHERE user_id = '{$order['user_id']}'";
$ret_w = $db->getRow($query_sql);
$wxid = $ret_w['wxid'];
$query_sql = "SELECT * FROM " . $ecs->table('order_goods') . " WHERE `order_id` = '{$order['order_id']}'";
$order_goods = $db->getAll($query_sql);
$orders = $db->getRow("SELECT * FROM " . $ecs->table('order_info') . " WHERE `user_id` = '{$order['user_id']}' AND `order_id` = '{$order['order_id']}'");
if (!empty($order_goods)) {
foreach ($order_goods as $v) {
if (empty($v['goods_attr'])) {
$shopinfo .= $v['goods_name'] . '(' . $v['goods_number'] . '),';
} else {
$shopinfo .= $v['goods_name'] . '(' . $v['goods_attr'] . ')(' . $v['goods_number'] . '),';
}
}
$shopinfo = substr($shopinfo, 0, strlen($shopinfo) - 1);
}
$wxch_address = "\r\n收件地址:" . $orders['address'];
$wxch_consignee = "\r\n收件人:" . $orders['consignee'];
$sql = "SELECT * FROM wxch_order WHERE id = 1";
$cfg_order = $db->getRow($sql);
$cfg_baseurl = $db->getOne("SELECT cfg_value FROM wxch_cfg WHERE cfg_name = 'baseurl'");
$cfg_murl = $db->getOne("SELECT cfg_value FROM wxch_cfg WHERE cfg_name = 'murl'");
$w_title = $cfg_order['title'];
$w_description = '商品信息:' . $shopinfo . "\r\n总金额:" . $orders['money_paid'] . "\r\n快递公司:" . $order['shipping_name'] . ' 单号:' . $order['invoice_no'] . $wxch_consignee . $wxch_address;
$w_url = $cfg_baseurl . $cfg_murl . 'user.php?act=order_detail&order_id=' . $order['order_id'] . '&wxid=' . $wxid;
if ($orders['pay_status'] == 0) {
$pay_status = '支付状态:未付款';
示例5: htmlspecialchars
consumer key: <?php echo htmlspecialchars($tmhOAuth->config['consumer_key']) ?></p>
<p>User Token: <?php echo htmlspecialchars($oauth_creds['oauth_token']) ?><br />
User Secret: <?php echo htmlspecialchars($oauth_creds['oauth_token_secret']) ?></p>
<?php*/
}
return false;
}
$params = uri_params();
if (!isset($params['oauth_token'])) {
// Step 1: Request a temporary token and
// Step 2: Direct the user to the authorize web page
request_token($tmhOAuth);
} else {
// Step 3: This is the code that runs when Twitter redirects the user to the callback. Exchange the temporary token for a permanent access token
$oauth_creds = access_token($tmhOAuth);
if ($oauth_creds && isset($oauth_creds['oauth_token']) && !empty($oauth_creds['oauth_token']) && isset($oauth_creds['oauth_token_secret']) && !empty($oauth_creds['oauth_token_secret'])) {
// yay we're connected to twitter!
// write these to the database so we can do stuff on the backend.
$twitter_account->update('twitter_name', $oauth_creds['screen_name']);
$twitter_account->update('twitter_id', $oauth_creds['user_id']);
$twitter_account->update('user_key', $oauth_creds['oauth_token']);
$twitter_account->update('user_secret', $oauth_creds['oauth_token_secret']);
$twitter_account->update('last_checked', time());
set_message('Successfully connected to Twitter');
redirect_browser(module_social_twitter::link_open($social_twitter_id));
} else {
echo 'Failed to connect to twitter';
echo $tmhOAuth->response['response'];
}
}
示例6: verify_credentials
}
// Step 4: Now the user has authenticated, do something with the permanent token and secret we received
function verify_credentials($tmhOAuth)
{
$tmhOAuth->config['user_token'] = $_SESSION['access_token']['oauth_token'];
$tmhOAuth->config['user_secret'] = $_SESSION['access_token']['oauth_token_secret'];
$code = $tmhOAuth->request('GET', $tmhOAuth->url('1/account/verify_credentials'));
if ($code == 200) {
echo $tmhOAuth->response['response'];
} else {
outputError($tmhOAuth);
}
}
/* Auth Flow */
if (isset($_REQUEST['wipe'])) {
// Logging out
wipe();
return;
}
if (isset($_REQUEST['start'])) {
// Let's start the OAuth dance
request_token($tmhOAuth);
} elseif (isset($_REQUEST['oauth_verifier'])) {
access_token($tmhOAuth);
} elseif (isset($_SESSION['access_token'])) {
// Some credentials already stored in this browser session.
verify_credentials($tmhOAuth);
} else {
// User's not logged in.
echo json_encode(array('loggedin' => false));
}
示例7: wxdownMediAapi
function wxdownMediAapi($mediaid, $openid)
{
if (!empty($mediaid)) {
$access_token = access_token();
file_put_contents('aa.txt', $access_token);
file_put_contents('bb.txt', $mediaid);
//下载图片
$url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token={$access_token}&media_id={$mediaid}";
$data = file_get_contents($url);
if (!empty($data)) {
$filename = 'user_' . $openid . '.jpg';
file_put_contents('./uploads/' . $filename, $data);
return $filename;
}
} else {
return false;
}
}
示例8: sInstDisplayMediaInfo
function sInstDisplayMediaInfo($media_id)
{
if (sIntCheckCache("mediainfo.json")) {
return sIntReadCache("mediainfo.json");
}
$apiurl = "https://api.instagram.com/v1/media/" . $media_id . "?access_token=" . access_token();
if (function_exists('curl_exec') && function_exists('curl_init')) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $apiurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);
curl_close($curl);
$data = json_decode($response, true);
file_put_contents(simply_instagram_plugin_path . '/cache-api/mediainfo.json', $response);
} else {
$response = wp_remote_get($apiurl, array('timeout' => 20));
$data = json_decode($response['body'], true);
file_put_contents(simply_instagram_plugin_path . '/cache-api/mediainfo.json', $response['body']);
}
return $data;
echo $data['data']['1']['filter'];
}
示例9: option_page_simply_instagram
function option_page_simply_instagram()
{
if (isset($_GET['tab'])) {
$_GET['tab'];
} else {
//wp_redirect( 'options-general.php?page=' . $this->plugin_options_key . '&tab=' . $this->si_general_settings . '&noheader=true' );
//exit;
}
/**
* Save info to database
* v1.2.5 uses wp options
*/
if (isset($_GET['access_token']) && isset($_GET['id'])) {
//$wpdb->insert( $wpdb->prefix . "instagram", array( 'access_token' => $_GET['access_token'], 'user_id' => $_GET['id'] ) );
update_option('si_access_token', $_GET['access_token']);
update_option('si_user_id', $_GET['id']);
}
/*
* Info query to check if database
* has record.
*/
//$info = $wpdb->get_results("select * from " . $wpdb->prefix . "instagram");
$info = array('si_access_token' => get_option('si_access_token'), 'si_user_id' => get_option('si_user_id'));
if (isset($_POST['sIntLogout']) == "log_out") {
/**
* v.1.2.6 Delete from wp options
*/
//$wpdb->query("delete from " . $wpdb->prefix . "instagram");
delete_option('si_access_token');
delete_option('si_user_id');
?>
<meta http-equiv="refresh" content="0;url=<?php
echo get_admin_url() . 'options-general.php?page=simply-instagram';
?>
"> <?php
}
?>
<div class="wrap">
<h2><?php
echo __('Simply Instagram Settings', 'simply-instagram');
?>
</h2>
<?php
if (!$info['si_access_token'] && !$info['si_user_id']) {
?>
<?php
if ($_GET['access_token'] == "" && $_GET['id'] == "") {
?>
<div class="error">
<p><?php
echo __('You did not authorize Simply Instagram. This plugin will not work without your authorization.', 'simply-instagram');
?>
</p>
</div>
<?php
}
?>
<a href=" <?php
echo sInstLogin('?return_uri=' . base64_encode(get_admin_url() . 'options-general.php?page=simply-instagram'));
?>
"><img src="<?php
echo plugins_url() . '/simply-instagram/images/instagram-login.jpg';
?>
" alt="<?php
echo __('Login to Instagram and authorize Simply Instagram plugin', 'simply-instagram');
?>
" /></a>
<?php
} else {
?>
<?php
if (isset($_GET['access_token']) && $_GET['id']) {
?>
<meta http-equiv="refresh" content="0;url=<?php
echo get_admin_url() . 'options-general.php?page=simply-instagram';
?>
"> <?php
}
?>
<iframe src="https://instagram.com/accounts/logout/" width="0" height="0">Logout</iframe>
<?php
$user_info = sInstGetInfo(user_id(), access_token());
//print_r( $user_info );
?>
<div id="sInts-welcome">
<img src="<?php
echo $user_info['data']['profile_picture'];
?>
" id="si_profile_photo"/>
<p id="si_username"><?php
echo __('Welcome', 'simply-instagram');
?>
<?php
echo $user_info['data']['full_name'];
?>
!</p>
//.........这里部分代码省略.........
示例10: widget
/** @see WP_Widget::widget */
function widget($args, $instance)
{
extract($args);
$widget_title = $instance['widget_title'];
$short_desc = $instance['short_desc'];
echo $before_widget;
echo $before_title . $widget_title . $after_title;
echo '<p>' . $short_desc . '</p>' . '<div class="clear"></div>';
echo sInstShowWidgetData(sInstGetRecentMedia(user_id(), access_token()), $instance['max_display'], $instance['size'], "sInstRecentMediaWid", $instance['display_caption'], $instance['open_instagram']);
?>
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function(){
jQuery("a[rel^='sInstRecentMediaWid']").prettyPhoto({
autoplay_slideshow: <?php
echo $instance['auto_play'];
?>
,
social_tools:false,
theme: '<?php
echo $instance['theme'];
?>
',
});
jQuery('.si-tooltip').tooltipster();
});
</script>
<?php
echo $after_widget;
}
示例11: create_menu
function create_menu($db)
{
access_token($db);
$ret = $db->getRow("SELECT `access_token` FROM `wxch_config`");
$access_token = $ret['access_token'];
if (strlen($access_token) >= 64) {
$url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' . $access_token;
$data = array();
$sql = "SELECT * FROM `wxch_menu` WHERE `aid` =0";
$data['first'] = $db->getAll($sql);
foreach ($data['first'] as $k => $v) {
if (empty($data['first'][$k]['name'])) {
unset($data['first'][$k]);
} else {
$data['first'][$k]['name'] = urlencode($v['name']);
if ($v['menu_type'] == 'click') {
$data['first'][$k]['array'] = array('type' => $v['menu_type'], 'name' => $data['first'][$k]['name'], 'key' => $v['value']);
} elseif ($v['menu_type'] == 'view') {
$data['first'][$k]['array'] = array('type' => $v['menu_type'], 'name' => $data['first'][$k]['name'], 'url' => $v['value']);
}
}
}
$sql = "SELECT * FROM `wxch_menu` WHERE `aid` =1";
$data['second1'] = $db->getAll($sql);
$second1 = 'no';
foreach ($data['second1'] as $k => $v) {
if (empty($data['second1'][$k]['name'])) {
unset($data['second1'][$k]);
} else {
$v['value'] = urlencode($v['value']);
$v['name'] = urlencode($v['name']);
if ($v['menu_type'] == 'click') {
$array1[] = array('type' => $v['menu_type'], 'name' => $v['name'], 'key' => $v['value']);
} elseif ($v['menu_type'] == 'view') {
$array1[] = array('type' => $v['menu_type'], 'name' => $v['name'], 'url' => $v['value']);
}
$second1 = 'yes';
}
}
$sql = "SELECT * FROM `wxch_menu` WHERE `aid` =2";
$data['second2'] = $db->getAll($sql);
$second2 = 'no';
foreach ($data['second2'] as $k => $v) {
if (empty($data['second2'][$k]['name'])) {
unset($data['second2'][$k]);
} else {
$v['value'] = urlencode($v['value']);
$v['name'] = urlencode($v['name']);
if ($v['menu_type'] == 'click') {
$array2[] = array('type' => $v['menu_type'], 'name' => $v['name'], 'key' => $v['value']);
} elseif ($v['menu_type'] == 'view') {
$array2[] = array('type' => $v['menu_type'], 'name' => $v['name'], 'url' => $v['value']);
}
$second2 = 'yes';
}
}
$sql = "SELECT * FROM `wxch_menu` WHERE `aid` =3";
$data['second3'] = $db->getAll($sql);
$second3 = 'no';
foreach ($data['second3'] as $k => $v) {
if (empty($data['second3'][$k]['name'])) {
unset($data['second3'][$k]);
} else {
$v['value'] = urlencode($v['value']);
$v['name'] = urlencode($v['name']);
if ($v['menu_type'] == 'click') {
$array3[] = array('type' => $v['menu_type'], 'name' => $v['name'], 'key' => $v['value']);
} elseif ($v['menu_type'] == 'view') {
$array3[] = array('type' => $v['menu_type'], 'name' => $v['name'], 'url' => $v['value']);
}
$second3 = 'yes';
}
}
if ($second1 == 'yes') {
$sarr1 = array('name' => $data['first'][0]['name'], 'sub_button' => $array1);
} elseif ($second1 == 'no') {
$sarr1 = $data['first'][0]['array'];
}
if ($second2 == 'yes') {
$sarr2 = array('name' => $data['first'][1]['name'], 'sub_button' => $array2);
} elseif ($second2 == 'no') {
$sarr2 = $data['first'][1]['array'];
}
if ($second3 == 'yes') {
$sarr3 = array('name' => $data['first'][2]['name'], 'sub_button' => $array3);
} elseif ($second3 == 'no') {
$sarr3 = $data['first'][2]['array'];
}
$arr = array('button' => array($sarr1, $sarr2, $sarr3));
$menu = urldecode(json_encode($arr));
$ret_json = curl_grab_page($url, $menu);
$ret = json_decode($ret_json);
if (!$ret->errcode == '0') {
$access_token = new_access_token($db);
$url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' . $access_token;
$ret_json = curl_grab_page($url, $menu);
$ret = json_decode($ret_json);
}
return $ret;
} else {
//.........这里部分代码省略.........
示例12: option_page_crum_simple_instagram
function option_page_crum_simple_instagram()
{
if (isset($_POST['sIntClearCache'])) {
sIntClearCache();
echo '<div id="message" class="updated fade"><p>Cache folder has been cleanup!</p></div>';
}
//check jpeg compression value
if (isset($_POST['JPEGCompression'])) {
if ($_POST['JPEGCompression'] > 100 || $_POST['JPEGCompression'] < 10) {
update_option('JPEGCompression', '80');
} else {
update_option('JPEGCompression', $_POST['JPEGCompression']);
}
}
global $wpdb;
/**
* Save info to database
* v1.2.5 uses wp options
*/
if (isset($_GET['access_token']) && isset($_GET['id'])) {
update_option('si_access_token', $_GET['access_token']);
update_option('si_user_id', $_GET['id']);
}
/*
* Info query to check if database
* has record.
*/
$info = array('si_access_token' => get_option('si_access_token'), 'si_user_id' => get_option('si_user_id'));
if (isset($_POST['sIntLogout']) == "log_out") {
delete_option('si_access_token');
delete_option('si_user_id');
?>
<meta http-equiv="refresh" content="0;url=<?php
echo get_admin_url() . 'options-general.php?page=crum-instagram';
?>
"> <?php
}
?>
<div class="wrap">
<div id="icon-plugins" class="icon32"></div><h2> Instagram</h2>
<?php
if (!$info['si_access_token'] && !$info['si_user_id']) {
?>
<?php
if ($_GET['access_token'] == "" && $_GET['id'] == "") {
?>
<div class="error">
<p>You did not authorize Instagram. This plugin will not work without your authorization. </p>
</div>
<?php
}
?>
<a href=" <?php
echo crInstLogin('?return_uri=' . base64_encode(get_admin_url() . 'options-general.php?page=crum-instagram'));
?>
"><img src="<?php
echo plugin_dir_url(__FILE__) . 'images/instagram-login.jpg';
?>
" title="Login to Instagram and authorize Instagram plugin" alt="Login to Instagram and authorize Instagram plugin" /></a>
<?php
?>
<?php
} else {
?>
<?php
if (isset($_GET['access_token']) && $_GET['id']) {
?>
<meta http-equiv="refresh" content="0;url=<?php
echo get_admin_url() . 'options-general.php?page=crum-instagram';
?>
"> <?php
}
?>
<iframe src="https://instagram.com/accounts/logout/" width="0" height="0">Logout</iframe>
<?php
$user = crInstGetInfo(user_id(), access_token());
?>
<div id="sInts-welcome">Welcome <?php
echo $user['data']['full_name'];
?>
. You can start using Instagram widget. You can find it in Apperance -> Widgets</div>
<form name="itw_logout" method="post" action="<?php
echo str_replace('%7E', '~', htmlentities(get_admin_url() . 'options-general.php?page=crum-instagram'));
?>
">
<input type="hidden" name="sIntLogout" value="log_out">
<input type="submit" class="button" value="Log out" name="logout" onclick="" >
</form>
<!-- END CSS -->
</div>
<?php
}
?>
<?php
//.........这里部分代码省略.........
示例13: ask_for_pin
function ask_for_pin()
{
echo 'What was the Pin Code?: ';
$handle = fopen("php://stdin", "r");
$data = fgets($handle);
return trim($data);
}
function access_token($tmhOAuth, $pin)
{
$code = $tmhOAuth->user_request(array('method' => 'POST', 'url' => $tmhOAuth->url('oauth/access_token', ''), 'params' => array('oauth_verifier' => trim($pin))));
if ($code == 200) {
$oauth_creds = $tmhOAuth->extract_params($tmhOAuth->response['response']);
// print tokens
echo <<<EOM
Congratulations, below is the user token and secret for {$oauth_creds['screen_name']}.
Use these to make authenticated calls to Twitter using the application with
consumer key: {$tmhOAuth->config['consumer_key']}
User Token: {$oauth_creds['oauth_token']}
User Secret: {$oauth_creds['oauth_token_secret']}
EOM;
} else {
echo "There was an error communicating with Twitter. {$tmhOAuth->response['response']}" . PHP_EOL;
}
die;
}
welcome();
request_token($tmhOAuth);
access_token($tmhOAuth, ask_for_pin());
示例14: get_code
<?php
include 'index.php';
if ($last_checkin[1] == 401) {
get_code();
}
if ($_GET['code']) {
$token = access_token($_GET['code']);
$last_checkin = get_checkins($token[0]['access_token']);
sql_connect($connection, $token[0]['access_token']);
echo "<p class='text-center'>" . $last_checkin[0]['response']['checkins']['items'][0]['venue']['location']['formattedAddress'][0] . "</p>";
}
示例15: access_token
} else {
echo "There was an error communicating with Twitter. {$tmhOAuth->response['response']}" . PHP_EOL;
die;
}
}
function access_token($tmhOAuth, $pin)
{
$code = $tmhOAuth->request('POST', $tmhOAuth->url('oauth/access_token', ''), array('oauth_verifier' => trim($pin)));
if ($code == 200) {
$oauth_creds = $tmhOAuth->extract_params($tmhOAuth->response['response']);
// print tokens
echo <<<EOM
Congratulations, below is the user token and secret for {$oauth_creds['screen_name']}.
Use these to make authenticated calls to Twitter using the application with
consumer key: {$tmhOAuth->config['consumer_key']}
User Token: {$oauth_creds['oauth_token']}
User Secret: {$oauth_creds['oauth_token_secret']}
EOM;
} else {
echo "There was an error communicating with Twitter. {$tmhOAuth->response['response']}" . PHP_EOL;
}
var_dump($tmhOAuth);
die;
}
welcome();
request_token($tmhOAuth);
$pin = tmhUtilities::read_input('What was the Pin Code?: ');
access_token($tmhOAuth, $pin);