thu*_*mal 5 google-calendar-api google-api-php-client
我正在尝试更新谷歌日历事件,但它不能使用默认日历..我的意思是当我使用'主'默认日历它不工作这是我的代码
const USER_EVENT_TYPE='primary';
const CLASS_EVENTS='Events';
if ($googleClient->getAccessToken())
{
if(!class_exists(self::CLASS_EVENTS))
{
$includeApplicationFiles=Mage::getBaseDir(self::LIBRARY_PATH);
foreach (glob($includeApplicationFiles.self::INCLUDE_ALL_FILES) as $retrieveFiles)
{
include $retrieveFiles;
}
$allCalendarEvents = $googleCalendar->events->listEvents(self::USER_EVENT_TYPE);
foreach ($allCalendarEvents->getItems() as $getSingleEvent) {
if($selectedEventValue==$getSingleEvent->summary)
{
$getSingleEvent->setSummary($selectedEventValue);
$addEventGuests = new Google_EventAttendee();
$addEventGuests->setEmail($selectGuestValue);
$invitedGuests = array($addEventGuests);
$getSingleEvent->attendees = $invitedGuests;
$updatedEvent = $googleCalendar->events->update(self::USER_EVENT_TYPE, $getSingleEvent->getId(),$getSingleEvent);
}
}
}
}Run Code Online (Sandbox Code Playgroud)
有这样的错误
<br />
<b>Fatal error</b>: Uncaught exception 'Google_ServiceException' with message 'Error calling PUT https://www.googleapis.com/calendar/v3/calendars/primary/events/5vmet3i6mmak81utnj2p0ebv8g?key=900220817963%40developer.gserviceaccount.com: (403) Forbidden' in C:\xampp\htdocs\magento\lib\google-api-php-client\src\io\Google_REST.php:61
Stack trace:
#0 C:\xampp\htdocs\magento\lib\google-api-php-client\src\io\Google_REST.php(35): Google_REST::decodeHttpResponse(Object(Google_HttpRequest))
#1 C:\xampp\htdocs\magento\lib\google-api-php-client\src\service\Google_ServiceResource.php(152): Google_REST::execute(Object(Google_HttpRequest))
#2 C:\xampp\htdocs\magento\lib\google-api-php-client\src\contrib\Google_CalendarService.php(591): Google_ServiceResource->__call('update', Array)
#3 C:\xampp\htdocs\magento\app\code\local\Social\Google\Model\Google.php(360): Google_EventsServiceResource->update('primary', '5vmet3i6mmak81u...', Object(Google_Event))
#4 C:\xampp\htdocs\magento\Connectors\google\AutoCompleteCalendarEvents.php(16): Social_Goog in <b>C:\xampp\htdocs\magento\lib\google-api-php-client\src\io\Google_REST.php</b> on line <b>61</b><br />
Run Code Online (Sandbox Code Playgroud)
小智 0
在没有看到您的所有代码的情况下,我会提出两个建议:
您可以更新密钥并在开发者控制台中检查您的设置。如果您更改了项目命名空间并使用相同的密钥,则可能会遇到问题。
另一件事是,如果您在任何地方设置了开发者密钥来删除它:
$googleClient->setDeveloperKey('insert_key');
Run Code Online (Sandbox Code Playgroud)
如果您阅读以下链接,它会显示一系列类似的问题。
https://code.google.com/p/google-api-php-client/issues/detail?id=218
我应该补充一点,这403 Forbidden表明您正在成功与服务器通信,但您缺乏该操作/操作的权限。
这就是为什么它倾向于:
1.密钥无效,或者
2.如果密钥有效,并且您已经覆盖了代码中的有效密钥值。从而呈现一个新值,(当然)这是一个无效的键。
如果您需要更多帮助,请告诉我。
| 归档时间: |
|
| 查看次数: |
341 次 |
| 最近记录: |