本文整理汇总了PHP中getAccessToken函数的典型用法代码示例。如果您正苦于以下问题:PHP getAccessToken函数的具体用法?PHP getAccessToken怎么用?PHP getAccessToken使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getAccessToken函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNumAudience
function getNumAudience($code, $gender, $accessToken)
{
global $aux_num_intentos, $num_intentos, $data_acount_facebook, $data_acount_facebook_index;
$numAudience = "";
$ban = 0;
while ($ban == 0) {
try {
$datos = file_get_contents('https://graph.facebook.com/act_' . $data_acount_facebook[$data_acount_facebook_index]['accountId'] . '/reachestimate?endpoint=/act_' . $data_acount_facebook[$data_acount_facebook_index]['accountId'] . '/reachestimate&accountId=' . $data_acount_facebook[$data_acount_facebook_index]['accountId'] . '&locale=es_LA&targeting_spec={"genders":[' . $gender . '],"age_max":65,"age_min":13,"broad_age":true,"regions":[],"countries":["' . $code . '"],"cities":[],"zips":[],"radius":0,"keywords":[],"connections":[],"excluded_connections":[],"friends_of_connections":[],"relationship_statuses":null,"interested_in":[],"college_networks":[],"college_majors":[],"college_years":[],"education_statuses":[0],"locales":[],"work_networks":[],"user_adclusters":[]}&method=get&access_token=' . $accessToken);
$datosarray2 = json_decode($datos, true);
$numAudience = $datosarray2['users'];
if ($numAudience != "" && is_numeric($numAudience)) {
$ban = 1;
} else {
sleep(3);
//Espera 3 minutos
$accessToken = getAccessToken();
//Trata de obtener un nuevo access_token
}
} catch (Exception $e) {
if ($aux_num_intentos++ > $num_intentos) {
informarError();
}
sleep(3);
//Espera 3 minutos
$accessToken = getAccessToken();
//Trata de obtener un nuevo access_token
}
}
return $numAudience;
}
示例2: getWxUserByOpenid
function getWxUserByOpenid($openid)
{
$access_token = getAccessToken();
$param = array('access_token' => $access_token, 'openid' => $openid, 'lang' => 'zh_CN');
$url = "https://api.weixin.qq.com/cgi-bin/user/info";
//获取userinfo"
$resp = SimpleHttpClient::get($url, $param);
$resp = parseResponse($resp);
return $resp;
}
示例3: __construct
/**
* 构造函数
*
*
*/
public function __construct()
{
parent::__construct();
$this->wxWechatModel = D('WxWechat');
$this->wxUserModel = D('WxUser');
$this->wxGoodsModel = D('WxGoods');
$this->wxGoodsCategoryModel = D('WxGoodsCategory');
/* 微信入口进来,从微信获取用户信息 */
if (isset($_GET['code'])) {
$AccessToken = getAccessToken();
$appid = C('APPID');
$secret = C('APPSECRET');
$msg = file_get_contents('https://api.weixin.qq.com/sns/oauth2/access_token?appid=' . $appid . '&secret=' . $secret . '&code=' . $code . '&grant_type=authorization_code');
$merchantOpenid = json_decode($msg, true);
/* 通过openid从数据库获取用户的微信信息 */
$merchantWechat = $this->wxWechatModel->getWechat($merchantOpenid['openid']);
if (!$merchantWechat) {
/* 如果本地数据库中不存在,则从微信服务器获取 */
$requestUrl = 'https://api.weixin.qq.com/sns/userinfo?access_token=' . $accessToken . '&openid=' . $merchantOpenid . '&lang=zh_CN';
$getMerchantWechat = file_get_contents($requestUrl);
$merchantWechat = json_decode($getMerchantWechat, true);
}
/* 如果数据库中获取失败,同时也不能从微信服务器获取用户信息,提示失败 */
if (!$merchantWechat) {
die('Param fail');
}
/* 把商户微信个人资料存入session */
session('merchantWechat', $merchantWechat);
}
/* 测试数据start:模拟登陆 */
$testStr = '{
"subscribe": 1,
"openid": "oaQ8auGYY-uQTtIUAFFxqnQJpjWQ",
"nickname": "Jahng",
"sex": 1,
"language": "zh_CN",
"city": "广州",
"province": "广东",
"country": "中国",
"headimgurl": "http://wx.qlogo.cn/mmopen/w9h84ibs6ic2cwVYeJTqmRtNpkhXTqYMrAGA5mAW6d5rPQ4qHvDuSkaTlrWEEf1v8icFFOrITC8MRvBrKz3Es35PzqpO7zic10CD/0",
"subscribe_time": 1426411696,
"remark": ""
}';
$merchantWechat = json_decode($testStr, true);
session('merchantWechat', $merchantWechat);
/* 测试数据end */
/* 如果没有商户微信信息,访问失败 */
if (!session('merchantWechat')) {
die('Param fail');
}
/* 获取用户的微信个人信息 */
$this->merchantWechat = session('merchantWechat');
/* 获取用户微销平台个人信息 */
$this->merchantUser = $this->wxUserModel->getUser(array('openid' => $this->merchantWechat['openid']));
}
示例4: getFilter
function getFilter($currPage, $keyword, $availability, $industry)
{
$consumer_key = KEY;
$consumer_secret = SECRET;
$req_url = 'https://public-api.expertfile.com/v1/organization/' . ID . '/getfilters';
$oauth = getAccessToken($consumer_key, $consumer_secret, $req_url);
$req_url = $req_url;
$params = http_build_query($oauth);
$ch = curl_init($req_url . '?' . $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$responsefromwcf = curl_exec($ch);
curl_close($ch);
$responseData = json_decode(urldecode($responsefromwcf));
return $responseData;
}
示例5: getResults
function getResults()
{
$consumer_key = KEY;
$consumer_secret = SECRET;
$req_url = 'https://public-api.expertfile.com/v1/organization/' . ID . '/search';
$oauth = getAccessToken($consumer_key, $consumer_secret, $req_url);
$parameters = array('fields' => urlencode('user:firstname,user:lastname,user:job_title,tagline,user:location:city,user:location:state,user:location:country'), 'keywords' => urlencode(''), 'location' => urlencode(''), 'industry' => urlencode(''), 'portfolio' => urlencode(''), 'availability' => urlencode(''), 'fee_min' => urlencode(''), 'fee_max' => urlencode(''), 'page_number' => urlencode(1), 'page_size' => 99999, 'keyword' => urlencode(''));
$req_url = $req_url;
$params = http_build_query($oauth) . '&' . http_build_query($parameters);
$ch = curl_init($req_url . '?' . $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$responsefromwcf = curl_exec($ch);
curl_close($ch);
$responseData = json_decode($responsefromwcf);
return $responseData;
}
示例6: lzmatch_request
function lzmatch_request()
{
$ak = getAccessToken();
if ($ak) {
$matchKey = $_REQUEST['key'];
$matchData = getMatch($ak, $matchKey, 'full_card');
wp_send_json(array('data' => $matchData));
exit;
} else {
setAccessToken();
$ak = getAccessToken();
if ($ak) {
lzmatch_request();
} else {
die('Error');
}
}
}
示例7: nextAccessToken
function nextAccessToken()
{
global $accessToken_data, $accessToken_data_index, $accessToken, $accountId, $nun_intentos, $max_nun_intentos;
$accessToken_data_index++;
if ($accessToken_data_index < count($accessToken_data)) {
$accessToken = $accessToken_data[$accessToken_data_index]['access_token'];
$accountId = $accessToken_data[$accessToken_data_index]['accountId'];
} else {
$nun_intentos++;
if ($nun_intentos < $max_nun_intentos) {
setAccessToken();
$accessToken_data = getAccessToken();
$accessToken_data_index = -1;
nextAccessToken();
} else {
informarErrorActividades();
}
}
}
示例8: nextAccessToken
function nextAccessToken()
{
global $accessToken_data, $accessToken_data_index, $accessToken, $accountId, $pageId, $pageName, $nun_intentos, $max_nun_intentos;
$accessToken_data_index++;
if ($accessToken_data_index < count($accessToken_data)) {
$accessToken = $accessToken_data[$accessToken_data_index]['access_token'];
$accountId = $accessToken_data[$accessToken_data_index]['accountId'];
$pageId = $accessToken_data[$accessToken_data_index]['pageId'];
$pageName = $accessToken_data[$accessToken_data_index]['pageName'];
} else {
$nun_intentos++;
if ($nun_intentos < $max_nun_intentos) {
setAccessToken();
$accessToken_data = getAccessToken();
$accessToken_data_index = -1;
nextAccessToken();
} else {
send_email('country_language_3_1', 'Owloo ERROR - Pais LANGUAGE 3.1', 'ERROR en la captura de datos.', true, 'Access Token - Pais LANGUAGE - ID = ' . $_SERVER['argv'][1]);
}
}
}
示例9: getJsApiTicket
function getJsApiTicket($appId, $appSecret)
{
// jsapi_ticket 应该全局存储与更新,以下代码以写入到文件中做示例
$ticket = _ROOT_ . "/jsapi_ticket.json";
//$data = json_decode(file_get_contents("jsapi_ticket.json"));
$data = json_decode(file_get_contents($ticket));
if ($data->expire_time < time()) {
$accessToken = getAccessToken($appId, $appSecret);
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token={$accessToken}";
$res = json_decode(httpGet($url));
$ticket = $res->ticket;
if ($ticket) {
$data->expire_time = time() + 7000;
$data->jsapi_ticket = $ticket;
$fp = fopen($ticket, "w");
fwrite($fp, json_encode($data));
fclose($fp);
}
} else {
$ticket = $data->jsapi_ticket;
}
return $ticket;
}
示例10: getYearlyDashboardMetrics
function getYearlyDashboardMetrics()
{
global $coll;
$query = $coll->findOne(array('username' => $_SESSION["username"]));
$refresh_token = $query['ga_refresh_token'];
$property = $query['ga_web_property']['ga_property_id'];
$access_token = getAccessToken($refresh_token);
$endDate = date('Y-m-d');
$startDate = date('Y-m-d', strtotime('-365 day'));
if (isset($property)) {
//Get daily visits and new visits for the last month
$url = 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga:' . $property . '&start-date=' . $startDate . '&end-date=' . $endDate . '&metrics=ga:visitors,ga:newVisits&dimensions=ga:year,ga:month';
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $access_token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return json_decode($data, true);
}
}
示例11: define
define('API_SECRET', 'a1580d3de5b915007796abfd3b72466e');
define('REDIRECT_URI', 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']);
define('SCOPE', 'read_stream');
// You'll probably use a database
session_name('facebook');
session_start();
// OAuth 2 Control Flow
if (isset($_GET['error'])) {
// LinkedIn returned an error
print $_GET['error'] . ': ' . $_GET['error_description'];
exit;
} elseif (isset($_GET['code'])) {
// User authorized your application
if ($_SESSION['state'] == $_GET['state']) {
// Get token so you can make API calls
getAccessToken();
} else {
// CSRF attack? Or did you mix up your states?
exit;
}
} else {
if (empty($_SESSION['expires_at']) || time() > $_SESSION['expires_at']) {
// Token has expired, clear the state
$_SESSION = array();
}
if (empty($_SESSION['access_token'])) {
// Start authorization process
getAuthorizationCode();
}
}
// Congratulations! You have a valid token. Now fetch your profile
示例12: getAccessToken
<?php
include_once 'modules/config.php';
if (!loggedIn()) {
echo '<script> window.location="login.php"; </script> ';
} else {
$query = $coll->findOne(array('username' => $_SESSION["username"]));
$refresh_token = $query['ga_refresh_token'];
if (!isset($query['ga_refresh_token'])) {
echo '<script> window.location="' . $get_ga_code_url . '"; </script> ';
} else {
$access_token = getAccessToken($refresh_token);
//Get web properties for account
if (isset($access_token)) {
$result_properties = getWebProperties($access_token);
foreach ($result_properties['items'] as $obj_add) {
$dropdown_add .= "<option value='" . $obj_add['id'] . "*" . $obj_add['name'] . "'>" . $obj_add['name'] . "</option>";
}
foreach ($query['ga_web_property'] as $obj_delete) {
$dropdown_delete .= "<option value='" . $obj_delete['ga_property_id'] . "'>" . $obj_delete['ga_property_name'] . "</option>";
}
}
}
if (isset($_POST['property_add'])) {
$try = explode('*', $_POST['property_add']);
$ga_property_id = $try[0];
$ga_property_name = $try[1];
setWebProperty($query['username'], $ga_property_id, $ga_property_name);
echo '<script>parent.window.location.reload(true);</script>';
}
if (isset($_POST['property_delete'])) {
示例13: getAccessToken
<?php
/*
* 菜单管理页面
*
*/
global $token;
$token = getAccessToken();
function requestMenu()
{
global $token;
$url = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=" . $token;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
return $res;
}
if (isset($_POST['sectionCount'])) {
$sectionCount = $_POST['sectionCount'];
$menu = [];
for ($idx = 0; $idx < $sectionCount; $idx++) {
$subMenu = [];
for ($idy = 0; $idy < 5; $idy++) {
if (!empty($_POST[$idx . '_subName_' . $idy]) && $_POST[$idx . '_subName_' . $idy] != 'none') {
$subMenu[$idy] = getCorrectSubmenu($idx, $idy);
}
}
if (!empty($_POST[$idx . '_menu'])) {
$menu[$idx] = getCorrectMainMenu($idx, $subMenu);
示例14: home_select_booktype_unique_mobile
public function home_select_booktype_unique_mobile()
{
$ret->status = 0;
$ret->msg = 'No Data';
if ($_REQUEST['code']) {
//just authenticated the application
$params->app_id = $this->config->item('fb_appkey');
//$params->redirect_url = $this->config->item('fb_canvaspage') . '/main/home_select_booktype/';
$params->redirect_url = $this->config->item('fb_canvaspage') . '/main/filter_page/';
$params->app_secret = $this->config->item('fb_appsecret');
$params->code = trim($_REQUEST['code']);
$token_info = getAccessToken($params);
$user = getFacebookUserDetails($params);
//setcookie("hardcover_fbid", $user->id, 0,'/');
//setcookie("hardcover_token", $token_info->access_token,0,'/'); //expires in 2hrs
$this->retrieve_fbdata($user->id, $token_info->access_token);
$this->start_create_book();
} else {
//this is creating another book
$ret->status = 1;
$ret->msg = '';
//$this->start_create_book();
//$this->start_create_book();
}
$param = new stdClass();
$param->book_info_id = $_COOKIE['hardcover_book_info_id'];
$param->facebook_id = $_COOKIE['hardcover_fbid'];
$data['token'] = $_COOKIE['hardcover_token'];
$data['book_filter'] = $this->filter_model->get_filter($param);
$data['user_albums'] = $this->filter_model->get_user_albums($param);
$data['user_albums_data'] = array();
$p_data = '';
foreach ($data['user_albums'] as $k1 => $v1) {
$p_data = '';
$param->album_id = $v1->album_id;
$photo_data = $this->filter_model->get_album_photos($param);
if (count($photo_data) > 0) {
$p_data .= '<ul style="display:none;" class="alb_photo hide albb_' . $v1->album_id . '" id="photos_from_album" >';
foreach ($photo_data as $k => $v) {
$p_data .= '<li><img src="' . $v->small . '"/><br/><center><input type="checkbox" name="photo[' . $v1->album_id . '][' . $v->fb_dataid . ']" id="photo_' . $v->fb_dataid . '" value="' . $v->fb_dataid . '" /></center></li>';
}
$p_data .= '</ul>';
}
$data['user_albums_data'][$v1->album_id] = $p_data;
}
// print_r($data); exit;
$ret->data = $this->load->view('filter_page_new_unique_mobile', $data, TRUE);
echo json_encode($ret);
}
示例15: define
<?php
define('ROOT_PATH', realpath(dirname(__FILE__)) . '/');
require_once 'vendor/autoload.php';
require_once 'src/config.php';
require_once 'src/google.php';
require_once 'src/spreadsheet.php';
require_once 'src/insert.php';
//-----------------------------------------------------------------------------
$entries = readFromFile(ROOT_PATH . $iniSettings['bug_file']);
if (count($entries) == 0) {
echo "No Entries";
exit;
}
//-----------------------------------------------------------------------------
$accessToken = getAccessToken($client);
$spreadsheet = getSpreadsheet($accessToken, $iniSettings['sheet_title']);
$worksheetFeed = $spreadsheet->getWorksheets();
$worksheet = $worksheetFeed->getByTitle('Reported Typos');
//-----------------------------------------------------------------------------
$results = insertLine($worksheet, $entries);
echo json_encode($results);