百度熊掌号运营位设置:
在账号中设置或获取:
开发信息:
用户名: 密码:
ClientId:账号获取
ClientSecret:账号获取
服务器配置:
URL:自己添加填写网址(底部附php文件内容)
Token:自行设置,加入到URL中
Encoding AESKey:账号获取
获取 access_token:
access_token:以上网址获取,有效时间为2小时
获取运营位状态:
https://openapi.baidu.com/rest/2.0/cambrian/home/operationstatus?access_token=ACCESS_TOKEN
添加运营位信息:
<?php
/**
* 用sha1算法生成安全签名
* @param string $strToken 票据
* @param string $intTimeStamp 时间戳
* @param string $strNonce 随机字符串
* @param string $strEncryptMsg 密文消息
* @return string
*/
function getSHA1($strToken, $intTimeStamp, $strNonce, $strEncryptMsg = '')
{
$arrParams = array(
$strToken,
$intTimeStamp,
$strNonce,
);
if (!empty($strEncryptMsg)) {
array_unshift($arrParams, $strEncryptMsg);
}
sort($arrParams, SORT_STRING);
$strParam = implode($arrParams);
return sha1($strParam);
}
//测试代码示例
$TOKEN = '此处填写你的token';
$strSignature = getSHA1($TOKEN, $_GET['timestamp'], $_GET['nonce']);
if ($strSignature == $_GET['signature']) {
echo $_GET['echostr'];
} else {
//校验失败
echo 'failed';
}