我拥有自定义渠道的AdSense帐户我做了所有事情,但有两个问题:
我的数据:
{
"access_token" : "XXXX.XXXX",
"token_type" : "XXXX",
"expires_in" : XXXX,
"created" : XXXX
}
我的更新声明:
$access_token_update = json_decode($access_token);
$access_token_update->created = time();
我收到此错误消息:
(401)凭证无效
我的代码:
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setAccessType('offline');
$client->setAccessToken($access_token);
$service= new Google_Service_AdSense($client);
答案 0 :(得分:1)
执行此视频中的步骤
https://www.youtube.com/watch?v=hfWe1gPCnzc
从结果示例中保存代码
{
"access_token": "XXXXXXXX",
"token_type": "XXXX",
"expires_in": XXXX,
"refresh_token": "XXXXXXXXX"
}
然后按以下步骤更新您的文件
$access_token = "from database or file or what you want to save"; // this will be code you got by doing steps in this video.
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setAccessType('offline');
$access_token_json = json_decode($access_token);
$client->refreshToken($access_token_json ->refresh_token);
$service= new Google_Service_AdSense($client);
享受:)谢谢