0

if anyone knows how I can publish something on google + using PHP. I used Google plus Domains API, but it only give access for read. If I can do it by g suite please tell me how can I do it.

//add code

$client = new \Google_Client();
    $client>setAccessToken(unserialize(get_option('google_access_token')));
    $plus = new \Google_Service_Plus($client);
    $plusDomain = new \Google_Service_PlusDomains($client);
    $activity = new \Google_Service_PlusDomains_Activity();
    $obj = new \Google_Service_PlusDomains_ActivityObject();
    try{

        $userId = $plusDomain->people->get('me')->id;



        $obj->setContent("Test text");
        $obj->setActor($userId);

        $activity->setObject($obj);
        $activity->setActor($userId);

        $activity->setTitle("title");


        $plusDomain->insert($userId,$activity);

on line setActor my code not continue http://i.prntscr.com/yM7xybRnTzy8H97jY7DKCg.png

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449

1 Answers1

0

There are two different APIs, and your question appears to be combining them. The Google+ api used grants read only access to the Google+ social media website. The Google plus domains api which gives you access to post to your Google plus domains account (gsuite).

You say you want to post to Google+ assuming that you mean the social media website then the answer is you cant the Google+ api as already stated is read only.

Your code appears to be using the Google+ domains api which you need to make sure that the user you are authenticating with has access to a google+ domains account if its not working have the Admin check the users access to the domain account

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Thank you for answer DalmTo, Now I have all access to google domain, but when I want post something, it no do. I read many comment and on here and on other system but not find good result ! – Norayr Baghdasarov Nov 10 '17 at 13:44
  • Check with the domain admin you may have to set it up https://developers.google.com/+/domains/authentication/delegation Unfortunately i dont have access to a domains account so i cant help you test it. – Linda Lawton - DaImTo Nov 10 '17 at 13:48