phpcurlgoogle-apigoogle-domain-api

Post in Google+ Domains using web tools


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


Solution

  • 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