new post to google plus
I want to use php to post to google plus. But google plus return "403 forbidden" I want you to give me a piece of code to make it possible.
This is my auth function :
global $client;
$client->setAuthConfig("/home/----");
$client->setRedirectUri("----");
$client->addScope("https://www.googleapis.com/auth/plus.stream.write");
$client->addScope("https://www.googleapis.com/auth/plus.me");
$authUrl = $client->createAuthUrl();
header("Location: $authUrl");
die;
And this is my new post function :
$client->setAccessToken($token);
$plus = new Google_Service_Plus($client);
$plusdomains = new Google_Service_PlusDomains($client);
$postBody = new Google_Service_PlusDomains_Activity();
$postBody['object']['originalContent'] = 'Happy Monday!';
$result = $plusdomains->activities->insert('me', $postBody);
$result = $plus->people->get('me');
$response->getBody()->write(var_export($result, true));
but the result is :
{ "error": { "errors": [ { "domain": "global", "reason": "forbidden", "message": "Forbidden" } ], "code": 403, "message": "Forbidden" } }
As you know ,many sites are now available that send new posts using google oauth to all kind of google plus account ( not only google apps ) ( for example : buffer.com)
Please help me
Hello.
You are making two calls to the API and writing both to $result, which is confusing. Do any calls to the API return as expected? If not, then I'd guess your access token is invalid.
Can you verify that the $token being passed to the client is a valid access token?
Try the google plus example shown here and see if you have any luck
Thanks for your attention token is valid because I return that in every request But every thing I do , I will see "Forbidden 403". Would you please give me a piece of code that post to google plus page ? The bad thing is I try the google api explorer And I get 403 Forbidden too. If you give me a code that works , You resolve my problem.
Closing this issue due to inactivity. Please let me know if you were able to get this working.
Nope
Which email address are you using? If the email address of the that you are using ends with gmail.com, then it won't work. The Domains API only works with apps.google.com accounts that use custom domains.
I need an account in apps.google.com, soo i m going to buy to post in google plus. Which plan i need to buy.???