小编eMa*_*ine的帖子

从Google服务帐户编辑Google日历活动:403

我想在服务帐户的Google日历中创建新活动.我可以正确访问并打印所有日历列表.但是当我想要创建一个新事件时,响应是403 Forbidden.

我的代码:

require_once 'src/Google_Client.php';
require_once 'src/contrib/Google_CalendarService.php';

session_start();

const CLIENT_ID = 'XXXXXXXXXX.apps.googleusercontent.com';
const SERVICE_ACCOUNT_NAME = 'XXXXXXXXXXXX@developer.gserviceaccount.com';

const KEY_FILE = 'google_src/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-privatekey.p12';

$client = new Google_Client();
$client->setApplicationName("APP_NAME");

if (isset($_SESSION['token'])) {
 $client->setAccessToken($_SESSION['token']);
}

$key = file_get_contents(KEY_FILE);
$client->setClientId(CLIENT_ID);
$client->setAssertionCredentials(new Google_AssertionCredentials(
  SERVICE_ACCOUNT_NAME,
  'https://www.google.com/calendar/feeds/MY_CALENDAR_ID/private/full/',
  $key)
);

$client->setClientId(CLIENT_ID);
$cal = new Google_CalendarService($client);
$event = new Google_Event();
$event->setSummary('Bon dia pel matí!');
$event->setLocation('Somewhere');
$start = new Google_EventDateTime();
$start->setDateTime('2012-08-06T10:00:00.000-07:00');
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime('2012-09-06T10:25:00.000-07:00');
$event->setEnd($end);

$createdEvent = $cal->events->insert(CALENDAR_NAME, $event);
Run Code Online (Sandbox Code Playgroud)

和服务器响应:

(403) Forbidden
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?也许其他范围,或允许编辑事件(我不知道我可以配置这个,我已经搜索过,承诺)

当然,我的日历是公共日历.

欢迎任何帮助:)

谢谢!

php google-calendar-api google-api

6
推荐指数
1
解决办法
1万
查看次数

Cordova 构建和 gradle 依赖项

嗯,一个在时间里像魅力一样运作的项目。

更新完整堆栈的多个部分后:

  • 净功率
  • 节点
  • 科尔多瓦
  • 安卓

现在,运行: cordova build

返回以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
 Could not resolve all dependencies for configuration ':_debugApk'.
    A problem occurred configuring project ':CordovaLib'.
       Could not resolve all dependencies for configuration ':CordovaLib:classpath'.
          Could not find com.android.tools.build:gradle:2.2.2.
           Searched in the following locations:
               https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom
               https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.jar
           Required by:
               android:CordovaLib:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option …
Run Code Online (Sandbox Code Playgroud)

android node.js cordova

3
推荐指数
1
解决办法
4986
查看次数

PDO ... SET NAMES utf8 危险吗?

看这里: http: //www.php.net/manual/en/mysqlinfo.concepts.charset.php

我明白使用

设置名称 utf8

这不是一个好主意,但尚不清楚:

  1. 有什么问题吗?
  2. 如何避免呢?
  3. 哪个实际上是在 PHP 3.6 或更高版本中为一个(或所有)PDO 连接设置字符集的解决方案?

我担心代码很危险:

$this->_conn = new PDO('mysql:host=host.name.blabla;dbname=my_database_name','username', 'password',array(
                PDO::ATTR_PERSISTENT => true,
                PDO::ATTR_ERRMODE    => PDO::ERRMODE_EXCEPTION,
                PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
            ));
Run Code Online (Sandbox Code Playgroud)

谢谢!

php mysql pdo utf-8 database-security

3
推荐指数
1
解决办法
3488
查看次数