duanjue6575 2016-06-08 11:50
浏览 55

传递给Google_Service_Directory_Groups_Resource :: insert的参数1必须是Google_Service_Directory_Group的实例,

I am trying to create a group using google directory api.

But i am getting this error

Catchable fatal error: Argument 1 passed to Google_Service_Directory_Groups_Resource::insert() must be an instance of Google_Service_Directory_Group, array given, called in C:\xampp\htdocs\groups\index.php on line 94 and defined in C:\xampp\htdocs\groups\google-api-php-client\src\Google\Service\Directory.php on line 2196

I have used this code

<?php

include_once 'google-api-php-client/src/Google/autoload.php';

$clientId = 'jkdjdjkdjkdjk';


$serviceAccountName = 'gserviceaccount.com';

$delegatedAdmin = 'myemailid@gmail.com';

$keyFile = 'myfile.p12';


$appName = 'Example App';


$scopes = array(
    'https://www.googleapis.com/auth/admin.directory.group'
);


$creds = new Google_Auth_AssertionCredentials(
    $serviceAccountName,
    $scopes,
    file_get_contents($keyFile)
);

$creds->sub = $delegatedAdmin;

/**
 * Create Google_Client for making API calls with
 */
$client = new Google_Client();
$client->setApplicationName($appName);
$client->setClientId($clientId);
$client->setAssertionCredentials($creds);


$dir = new Google_Service_Directory($client);


$postBody = array('email'=>'sales_group@domain.com');
    $list = $dir->groups->insert($postBody);
    print_r($list);
  • 写回答

1条回答 默认 最新

  • douhezhan5348 2016-11-23 16:50
    关注

    You need to change your array in $postBody for:

    $postBody = new Google_Service_Directory_Group();
    $postBody->email = 'sales_group@domain.com';
    
    $list = $dir->groups->insert($postBody);
    print_r($list);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀