Need to shorten links through the service goo.gl
using the API

got your API key.
set
pip install --upgrade google-api-python-client

How to do in the program code I do not know.
which module to import?
what API commands?
for example link www.google.com

Closed due to the fact that the question is too general for the participants Vadim Ovchinnikov , AK , Bald , user194374, Denis Bubnov 13 Jan '17 at 15:13 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    Do not read the documentation? developers.google.com/url-shortener/v1/getting_started - ilyaplot
  • the documentation is not clear to me, as in English. I would have a simple example. - Andrei Kruzlik
  • five
    Nobody will do anything for you here. Look for a performer for money at the appropriate resources. - ilyaplot
  • @ilyaplot: you misrepresent the goals and objectives of the site. Work for the author - jfs
  • @jfs Why, then, did 5 people rate my comment? Perhaps you incorrectly represent the goals and objectives of the site? Here they help people to understand their own code, and do not write free code for it. - ilyaplot

1 answer 1

To create a short goo.gl link short_url from a long link long_url , using the Google key api_key , you can issue an http POST request :

 import requests # $ pip install requests api_url = 'https://www.googleapis.com/urlshortener/v1/url' r = requests.post("{api_url}?key={api_key}".format(**vars()), json={'longUrl': long_url}) short_url = r.json()['id'] 

Full example goo_gl.py .