Posting on google profile to any user in php

89 views Asked by At

I want to posting on google plus account to any user who authenticate my app i have already create G-Suite account and i can also post on google plus account but i can not post on other user account who already done app authentication i want the functionality like a www.buffer.com application they can easily post on all the users who have verified the google profile so i want to know how they can post on google account and i can't upload activity on google+ accopunt.

    $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! 1" ,
  'attachments' => ['image'=>array('url'=>$img_path)]
), 

)
);

$newActivity = $service->activities->insert($user->id, $activity);    

var_dump($newActivity);

It will successfully post on my google plus account means my G-suit account login but whenever i am going to try to send post to on other account then it is not possible to send post on other normal account it will throwing me error like

ERROR :

"error": {
  "errors": [
   {
    "domain": "global",
    "reason": "forbidden",
    "message": "Forbidden"
   }
  ],
  "code": 403,
  "message": "Forbidden"
 }
1

There are 1 answers

4
abraham On

The Domains API can only be used by G Suite users. It doesn't matter who creates the app, it matters which specific account credentials are on each specific request.