我一直在尝试使用 PHP 访问 Google Calendar API v3。最初,我想简单地列出我可以通过 API 调用访问的用户日历。
为此,我下载了 Google API PHP 客户端库,并尝试使用以下代码(经过我的改编,来源自https://mytechscraps.wordpress.com/2014/05/15/accessing-google -calendar-using-the-php-api/):
<?php
//error_reporting(0);
//@ini_set('display_errors', 0);
// If you've used composer to include the library, remove the following line
// and make sure to follow the standard composer autoloading.
// https://getcomposer.org/doc/01-basic-usage.md#autoloading
require_once './google-api-php-client-master/autoload.php';
// Service Account info
$client_id = '754612121864-pmdfssdfakqiqblg6lt9a.apps.googleusercontent.com';
$service_account_name = '754674507864-pm1dsgdsgsdfsdfsdfdflg6lt9a@developer.gserviceaccount.com';
$key_file_location = 'Calendar-7dsfsdgsdfsda953d68dgdsgdsff88a.p12';
$client = new Google_Client();
$client->setApplicationName("Calendar");
$service = new Google_Service_Calendar($client);
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array('https://www.googleapis.com/auth/calendar.readonly'),
$key …Run Code Online (Sandbox Code Playgroud) php google-calendar-api google-api google-client google-api-php-client
如果您在谷歌日历中创建重复事件,您实际上创建了一个具有重复规则的单个事件(父事件),其他事件只是虚拟添加。一旦您移动任何这些虚拟对象,它就会保存为实例,您可以按照您喜欢的任何方式对其进行编辑,而不会影响父事件本身。
如果您编辑该实例以匹配其父实例,它将被删除并再次替换为虚拟实例。(不需要保留与父事件没有什么不同的实例,对吗?)
我在我的应用程序中也做了同样的事情。但是,当我尝试使用 google-php-api-client 执行此操作时,删除某些内容的唯一选择是将事件状态设置为“已取消”,这将使实例被删除。
我的问题是:
如何删除(或重置)实例而不需要一一更新它们以匹配其父实例?
编辑:忘记提及为什么我需要这个以及我想要实现什么目标。
基本上,如果您编辑一个实例,Google 会询问您是否要编辑“仅此”、“以下”或“全部”重复事件。如果您选择“以下”,Google 将丢弃从此日期 ( where original_start > date) 起与父事件相关的所有内容,修改其规则以设置UNTIL正在编辑的实例日期的规则,并将其旧规则传递给新创建的事件,其开始时间与此特定实例的日期。
因为我不知道如何删除符合某些条件的多个事件。我能解决这个问题的唯一方法是选择所有这些,然后一一更新它们,这可能会有点问题,因为您可以:
有没有办法使用 php 列出 Google Storage 中存储桶中的所有文件?我能够上传和下载文件,因为我找不到列出所有这些文件的方法?
在文档中有使用 java 或 python 列出的示例...但没有 PHP。
https://cloud.google.com/storage/docs/json_api/v1/objects/list
那么有什么想法吗?
谢谢你!
编辑我找到了一个解决方案。任何人都可以确认这是正确的方法吗?
我已经研究这个有一段时间了,根据我收集的信息,它与抽样级别有关。
我从大多数其他 stackoverflow 问题中收集到的问题是,除非我有高级帐户,否则数据将始终按采样返回。
值得一问的是,有没有办法可以改变我的 Google API 查询,以便数据更准确一点?
我的查询代码:
$profiles = $analytics->management_profiles
->listManagementProfiles('myID', '~all');
foreach ($profiles->getItems() as $profile) {
$IDvalue = $profile->getId();
array_push($profilesArray, $IDvalue);
}
foreach ($profilesArray as $p) {
$results = $analytics->data_ga->get(
'ga:' . $p,
'7daysAgo',
'today',
'ga:sessions');
$profileName = $results->getProfileInfo()->getProfileName();
$rows = $results->getRows();
$sessions = $rows[0][0];
print "Profile Name: $profileName";
echo "<br>";
print "Total Sessions: $sessions";
echo "<br><br>";
}
Run Code Online (Sandbox Code Playgroud)
我尝试将我的更改get()为:
$results = $analytics->data_ga->get(
'ga:' . $p,
'7daysAgo',
'today',
'ga:sessions',
'samplingLevel:HIGHER_PRECISION');
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
$results = $analytics->data_ga->get(
'ga:' …Run Code Online (Sandbox Code Playgroud) php google-analytics google-api google-analytics-api google-api-php-client
是否正在尝试过滤属性为 null 且属性同时具有 {key=1 和 value=1} 的文件?
这是我在请求中发送的查询字符串:
'q'=>"'$FolderId' in parents
and (appProperties has null or appProperties has { key='1_id' and
value='1' })"
Run Code Online (Sandbox Code Playgroud) 我正在使用Google Drive v3并尝试将 Google 电子表格文件导出为 PDF。几乎一切都按预期进行。
例外:
生成的 PDF 始终采用LETTER和PORTRAIT格式,但我需要DIN A4和横向格式的 pdf 。我无法找到任何设置/参数来提交到 v3 以生成其他格式的 PDF。
我找到了适用于 Google Drive v2 的解决方案,但没有找到适用于 Google Drive v3 的解决方案。
将格式或肖像作为可选参数传递会导致错误:-(
/**
* Downloads a Google file in a specified mime type.
*
* @param string $googleDriveFileId id of the drive file which should be downloaded
* @param string $mimeType mime type
* @param string[] $optParams
*
* @return Response
*
* …Run Code Online (Sandbox Code Playgroud) 我目前正在使用Youtube Analytics API,
到目前为止,我已经能够提取youtube提供的所有数据,除了性别/ ageGroup维度,查询每次都失败,
该文档点的例子来playbacklocation,而不是人口它的自我.
我正在使用PHP客户端库,
== PHP ==
$analytics_gender = new Google_YouTubeAnalyticsService($client);
$optparam = array('dimensions' => 'gender');
$metrics= "views";
$analytics_demo_gender = $analytics_gender->reports->query("channel==".$channelId, "2012-08-14", "2013-05-30", $metrics, $optparam);
Run Code Online (Sandbox Code Playgroud)
当我运行此查询时,我得到一个error (400) The query is not supported.即使它适用于所有其他指标和维度.
php youtube youtube-api google-api-php-client youtube-analytics
首先,我只想说出我需要从用户那里得到什么信息.
为了获得所有这些信息,我继续下载/安装了位于此处的PHP客户端库.
由于这是我第一次使用API,我环顾四周并找到了以下范围:
$client->setScopes(array('https://www.googleapis.com/auth/youtube.readonly', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email'));
Run Code Online (Sandbox Code Playgroud)
出于某种原因,当我运行这个:$myData = $GoogleData->userinfo->get('me');我得到这个:
Undefined property: Google_Service_Plus::$userinfo in path/test.php on line 61
不太确定我做错了什么,或者即使我应该使用Google Plus Api来获取这些信息.
我需要主帐户电子邮件(包含所有YouTube频道)和用户地址等.他们在Google帐户中注册了该电子邮件.我如何得到这些信息以及我在上面的例子中做错了什么?
我实际上创建了一个专门用于所有Google API的聊天室(转到这里)
这也让我想到了另一点.为什么文档过时而且没有得到解决.我看到的大多数例子都来自两年前,但我使用的是几个月前更新的内容.
情况
我正在为我的应用设置Gmail API.
我需要导入所有标有特定标签的电子邮件,例如TRASH,SPAM,SENT,UNREAD,STARRED等.
我可以获取收件箱电子邮件列表和单个邮件信息.我可以获得标签列表以及单个标签信息.但我没有找到如何将它们结合起来.
显然,在给定labelId的情况下,没有特定的请求来检索消息列表,并且在电子邮件列表中没有labelId的痕迹.
要求输出:
获取消息列表:
array(3) { [0]=> array(5) { ["messageId"]=> string(16) "14ddc24465a9b72e" ["messageSnippet"]=> string(14) "sample message" ["messageSubject"]=> string(4) "Test" ["messageDate"]=> string(22) "Jun 10th 2015 08:24 AM" ["messageSender"]=> string(44) "SENDER_NAME" } [1]=> array(5) { ["messageId"]=> string(16) "14dd8391372f3035" ["messageSnippet"]=> string(91) "buonasera Date: Tue, 9 Jun 2015 08:08:48 -0400 Message-Id: <CAGL50m_2vPv-Bkzbd+m5iFkx-u-" ["messageSubject"]=> string(4) "Test" ["messageDate"]=> string(22) "Jun 10th 2015 08:24 AM" ["messageSender"]=> string(44) "SENDER_NAME" } [2]=> array(5) { ["messageId"]=> string(16) "14dd7f4f126103c9" ["messageSnippet"]=> string(99) "Ciao meetinghand Suggerimenti per …Run Code Online (Sandbox Code Playgroud) 我对新的Google表格API v4感到困惑.我的问题是:如何在电子表格的开头插入一行?
我找不到任何有用的新Google Sheet API v4教程,也没有找到特定于PHP的Google可行文档.
php ×9
google-api ×4
youtube-api ×2
email ×1
gmail ×1
gmail-api ×1
google-plus ×1
list ×1
youtube ×1