PHP Authorization fail when post in google moment with plusapi
I think you have get authorization error because of following reason -
- Not setting email id & project name using developer console link
APIs & Auth->Consent Screen
. - You are calling deprecated API
$this->_CI->googleplus->item_scope->setId($post_data['gp_id']);
. To Call this you have to use this classnew Google_Service_Plus_ItemScope();
$this->_CI->googleplus->moment_body->setTarget($this->_CI->googleplus->item_scope);
.To call this method you have to use this classnew Google_Service_Plus_Moment()
;- I have setup demo code in git for you. Google-Plus-API-Codeigniter-Starter. You can use same code to start with. I have provided detailed instruction in git repository too.
You have to Register your application using Google Console Settings as below:
- Go to Google Developer Console
- Create Project
- To Get Google+ API Access go to: APIs & Auth->APIs -> enable Google+ API
- To Get client_id & client_secret go to: APIs & Auth->Credentials->Create new Client ID
- To Get api_key go to: APIs & Auth->Credentials->Create New Key->Browser key
- To Get application_name go to: APIs & Auth->Consent Screen
- Set Email Address
- Product Name
Note: Ensure you have get all the required access from google as mentioned in point 5
Conclustion: You are using Latest google-api-php-client client. And trying to call method in an older way. Hence its not working.