duanji2002 2015-08-30 00:56
浏览 69

Google API - 通过服务帐户访问日历

I keep getting this fatal error.

Fatal error: Uncaught exception 'Google_IO_Exception' with message 'HTTP Error: Unable to connect: 'fopen(https://accounts.google.com/o/oauth2/token): failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. ''

I am accessing it by a localhost on another computer using my network. I just attempted to reboot it and see it that solved it by some weird means. Did not work.

Here is my file.

    $client_id = $jsonDecode['client_id'];
    $Email_address = $jsonDecode['client_email'];    
    $key_file_location = 'privateKey.p12';      

    $client = new Google_Client();      
    $client->setApplicationName("<APP NAME>");
    $key = file_get_contents($key_file_location);    

// separate additional scopes with a comma   
$scopes ="https://www.googleapis.com/auth/calendar.readonly";   
$cred = new Google_Auth_AssertionCredentials(    
    $Email_address,      
    array($scopes),     
    $key         
    );      
$client->setAssertionCredentials($cred);
if($client->getAuth()->isAccessTokenExpired()) {        
    $client->getAuth()->refreshTokenWithAssertion($cred);       
}       

$service = new Google_Service_Calendar($client);    
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP