本文整理汇总了PHP中JSSDK::getAccessToken方法的典型用法代码示例。如果您正苦于以下问题:PHP JSSDK::getAccessToken方法的具体用法?PHP JSSDK::getAccessToken怎么用?PHP JSSDK::getAccessToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSSDK
的用法示例。
在下文中一共展示了JSSDK::getAccessToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: JSSDK
function download_voice($media_id)
{
require_once "jssdk.php";
$jssdk = new JSSDK("wxe90370e2554fa1d5", "862f2e0b551081b35c0887bcfd3fc978");
$accesstoken = $jssdk->getAccessToken();
copy('http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=' . $accesstoken . '&media_id=' . $media_id, 'voices/' . $media_id . '.amr');
exec('sox --norm voices/' . $media_id . '.amr granular-gh-pages/audio/' . $media_id . '.mp3');
exec('sox --norm voices/' . $media_id . '.amr granular-gh-pages/audio/sample.mp3');
}
示例2: saveMedia
<?php
require_once "jssdk.php";
require_once "config.php";
$server_id = $_POST['serverId'];
$jssdk = new JSSDK($wechat_config['appId'], $wechat_config['appSecret']);
$access_token = $jssdk->getAccessToken();
$media_id = $server_id;
$url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token={$access_token}&media_id={$media_id}";
saveMedia($url);
function saveMedia($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_NOBODY, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$package = curl_exec($ch);
$httpinfo = curl_getinfo($ch);
curl_close($ch);
$media = array_merge(array('mediaBody' => $package), $httpinfo);
preg_match('/\\w\\/(\\w+)/i', $media["content_type"], $extmatches);
$fileExt = $extmatches[1];
$filename = time() . rand(100, 999) . ".{$fileExt}";
// make sure the document chmod 777
file_put_contents($filename, $media['mediaBody']);
return $filename;
}
echo 'save media success';
示例3: httpGet
if ($access_token) {
$data->expire_time = time() + 7000;
$data->access_token = $access_token;
memcache_set($this->mmc, 'access_token', json_encode($data));
}
} else {
$access_token = $data->access_token;
}
return $access_token;
}
private function httpGet($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_URL, $url);
$res = curl_exec($curl);
curl_close($curl);
return $res;
}
}
$obj = new JSSDK('Your APP_ID', 'Your APP_SECRIET');
$access_token = $obj->getAccessToken();
//echo $access_token;
//$ticket = $obj->getJsApiTicket();
//echo $ticket;exit;
$url = $_REQUEST['url'];
$ticket = $obj->getSignPackage($url);
echo json_encode($ticket);
示例4: JSSDK
<?php
require_once "jssdk.php";
$jssdk = new JSSDK("YOURWEBID", "YOURSECRET");
$signPackage = $jssdk->getAccessToken();
echo "success";
?>