【问题标题】:Creating an google calendar event with gadget using google-api-php-client使用 google-api-php-client 使用小工具创建 google 日历事件
【发布时间】:2013-01-07 02:47:16
【问题描述】:

我有一个工作脚本正在我的谷歌日历中创建事件 - 使用 google-api-php-client。我正在尝试将 gadget 添加到它使用以下代码创建的每个事件中:

require_once "google-api-php-client/src/Google_Client.php";

require_once "google-api-php-client/src/contrib/Google_CalendarService.php";

define('CLIENT_ID', 'xxx...');

define('SERVICE_ACCOUNT_NAME', 'xxx...');

define('KEY_FILE', 'xxx...');

$client = new Google_Client();

$client->setApplicationName("WEB ACCTION");

$key = file_get_contents(KEY_FILE);

$client->setAssertionCredentials(new Google_AssertionCredentials(SERVICE_ACCOUNT_NAME,'xxx...',$key));

$client->setClientId(CLIENT_ID);

$service = new Google_CalendarService($client);

$event = new Google_Event();

$event->setSummary($variable1);

$event->setLocation($variable2 . ", " . $variable3);

$start = new Google_EventDateTime();

$start->setDateTime(date(DATE_ATOM, strtotime($variable4) + $time_offset));

$event->setStart($start);

$end = new Google_EventDateTime();

$end->setDateTime(date(DATE_ATOM, strtotime($variable5) + $time_offset));

$event->setEnd($end);

//The not working section

//$gadget = new Google_EventGadget();           
//$gadget->setIconLink('xxx...');
//$gadget->setTitle('xxx...');
//$gadget->setHeight('xxx...');
//$gadget->setWidth('xxx...');
//$gadget->setLink('xxx...');
//$gadget->setType('xxx...');
//$gadget->setDisplay('xxx...');
//$event->setGadget($gadget);

$createdEvent = $service->events->insert($g_calendar , $event);

不幸的是 - 我无法让它工作,也找不到任何有关使用 google-api-php-client 创建小工具的信息。该库包含一个 Google_EventGadget 类和 setGadget 函数,但没有关于如何使用它们的信息。谁能帮帮我?

【问题讨论】:

    标签: php google-calendar-api google-gadget google-api-php-client


    【解决方案1】:

    我找到了解决方案 - google-api-php-client 仅支持小工具及其图标的认证链接。在我使用 https://www... 链接之前它不起作用。

    即使我用于测试的主机没有安全证书,它也能正常工作。

    $gadget->setIconLink('https://www...');
    
    $gadget->setLink('https://www....');
    
    $gadget->setDisplay('chip');
    
    $gadget->setWidth('400');
    
    $gadget->setHeight('100');
    
    $event->setGadget($gadget);
    
    $createdEvent = $service->events->insert($g_calendar , $event);
    

    希望它能节省一些时间!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-24
      • 2017-01-24
      • 2014-03-24
      相关资源
      最近更新 更多