Google_Activity must be an instance of Google_ActivityObject

為{幸葍}努か 提交于 2019-12-06 05:01:32

The error here is that the activity object is not being properly built, hence the error "must be an instance of Google_Activity". There are different ways in which you can build the activity object to insert it as a comment in your G Suite Google Plus profile. Take for example the following approach.

$service = new Google_Service_PlusDomains($client);

$activity = new Google_Service_PlusDomains_Activity(
   array(
      'access' => array(
          'items' => array(
              'type' => 'domain'
          ),
          'domainRestricted' => true
      ),
      'verb' => 'post',
      'object' => array(
          'originalContent' => "Post using Google API PHP Client Library!" 
      ), 
   )
);

$newActivity = $service->activities->insert("me", $activity);    

var_dump($newActivity);

The reference documentation explains what are the required and optional properties the object must have. I strongly recommend you to build the object using an array as explained above. That should make it work. I hope this information helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!