diff --git a/README.md b/README.md index 5a45df08..e0f30e6f 100644 --- a/README.md +++ b/README.md @@ -311,6 +311,8 @@ Changelog * Don't enclose bare URLs in`<`/`>` ([snarfed/bridgy#850](https://github.com/snarfed/bridgy/issues/850)). * Atom: * Bug fix for actors and attachments with multiple image URLs. +* Google+: switch from deprecated global API endpoint to G+ endpoint. Background in [snarfed/bridgy#846](https://github.com/snarfed/bridgy/issues/846), [Google blog post](https://developers.googleblog.com/2018/03/discontinuing-support-for-json-rpc-and.html) [and docs](https://developers.google.com/api-client-library/python/guide/batch). + ### 1.14 - 2018-11-12 Add `delete()`. Currently includes Twitter and Flickr support. * Instagram: diff --git a/granary/googleplus.py b/granary/googleplus.py index 092e0453..3d3274c6 100644 --- a/granary/googleplus.py +++ b/granary/googleplus.py @@ -105,6 +105,7 @@ def get_activities_response(self, user_id=None, group_id=None, app_id=None, if user_id is None: user_id = 'me' + api = self.auth_entity.api() http = self.auth_entity.http() if etag: # monkey patch the ETag header in because google-api-python-client doesn't @@ -119,14 +120,14 @@ def request_with_etag(*args, **kwargs): # https://developers.google.com/+/api/latest/activities try: if activity_id: - call = self.auth_entity.api().activities().get(activityId=activity_id) + call = api.activities().get(activityId=activity_id) activities = [call.execute(http=http)] elif search_query: - call = self.auth_entity.api().activities().search( + call = api.activities().search( query=search_query, maxResults=min(count, SEARCH_MAX_RESULTS)) activities = call.execute(http=http).get('items', []) else: - call = self.auth_entity.api().activities().list( + call = api.activities().list( userId=user_id, collection='public', maxResults=count) resp = call.execute(http=http) activities = resp.get('items', []) @@ -147,13 +148,13 @@ def request_with_etag(*args, **kwargs): # prepare batch API requests for comments, likes and reshares # https://developers.google.com/api-client-library/python/guide/batch - batch = BatchHttpRequest() + batch = api.new_batch_http_request() for activity in activities: # comments id = activity['id'] num_replies = activity.get('object', {}).get('replies', {}).get('totalItems') if fetch_replies and num_replies and num_replies != cached.get('AGC ' + id): - call = self.auth_entity.api().comments().list(activityId=id, maxResults=500) + call = api.comments().list(activityId=id, maxResults=500) def set_comments(_, resp, exc, activity=None): obj = activity.get('object', {})