Python httplib2.Http() Examples

The following are 30 code examples for showing how to use httplib2.Http(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module httplib2 , or try the search function .

Example 1
Project: imgcomp-cvpr   Author: fab-jul   File: sheets_logger.py    License: GNU General Public License v3.0 6 votes vote down vote up
def check_connection(flags=None):
    """ Checks if link to google sheet is correctly set up. """
    try:
        credentials = _get_credentials(flags)
        http = credentials.authorize(httplib2.Http())
        discovery_url = 'https://sheets.googleapis.com/$discovery/rest?version=v4'
        service = discovery.build('sheets', 'v4', http=http, discoveryServiceUrl=discovery_url)

        title_cell = 'B2'
        title_cell_expected_content = 'Logs'

        result = service.spreadsheets().values().get(
            spreadsheetId=_get_spreadsheet_id(), range=title_cell).execute()
        values = result.get('values')
        if not values:
            raise GoogleSheetsAccessFailedException('No values found')
        if values[0][0] != title_cell_expected_content:
            raise GoogleSheetsAccessFailedException('Unexpected content found: {}'.format(values))
        print('Google Sheets connection established')
        return service
    except HttpError as e:
        raise GoogleSheetsAccessFailedException('HttpError: {}'.format(e)) 
Example 2
Project: GraphiPy   Author: shobeir   File: twitter_api.py    License: MIT License 6 votes vote down vote up
def __init__(self, api):
		self.consumer_key = api["consumer_key"]
		self.consumer_secret = api["consumer_secret"]
		self.access_token = api["access_token"]
		self.token_secret = api["token_secret"]

		bearer_token_credentials = self.consumer_key+':'+self.consumer_secret

		encoded_credentials = base64.b64encode(bearer_token_credentials.encode('utf-8')).decode('utf-8')
		headers = {
			'Authorization': 'Basic ' + encoded_credentials,
			'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
		url = "https://api.twitter.com/oauth2/token/?grant_type=client_credentials"
		http = httplib2.Http()
		response, content = http.request(url, method="POST", headers=headers)
		content = json.loads(content.decode("utf-8"))
		self.bearer_token = content["access_token"] 
Example 3
Project: GraphiPy   Author: shobeir   File: twitter_api.py    License: MIT License 6 votes vote down vote up
def fetch_tweets_by_topic(self, graph, keyword, limit=15):
		url = "https://api.twitter.com/1.1/search/tweets.json?q=" + keyword + "&count=" + str(limit)
		http = httplib2.Http()
		headers = {
			'Authorization': 'Bearer ' + self.bearer_token
		}
		response, content = http.request(url, method="GET", headers=headers)
		result = json.loads(content.decode())
		for tweet in result["statuses"]:
			single_tweet = TwitterTweet(tweet)
			graph.create_node(single_tweet)
			creator = TwitterUser(tweet["user"])
			graph.create_node(creator)
			graph.create_edge(Edge(single_tweet.get_id(), creator.get_id(), "CREATED_BY"))
			graph.create_edge(Edge(creator.get_id(), single_tweet.get_id(), "CREATED"))
			if 'retweeted_status' in tweet:
				original_tweet = TwitterTweet(tweet["retweeted_status"])
				graph.create_node(original_tweet)
				graph.create_edge(Edge(single_tweet.get_id(), original_tweet.get_id(), "RETWEET"))
				graph.create_edge(Edge(original_tweet.get_id(), single_tweet.get_id(), "RETWEETED BY"))
			if 'quoted_status' in tweet:
				original_tweet = TwitterTweet(tweet["quoted_status"])
				graph.create_node(original_tweet)
				graph.create_edge(Edge(single_tweet.get_id(), original_tweet.get_id(), "QUOTE"))
				graph.create_edge(Edge(original_tweet.get_id(), single_tweet.get_id(), "QUOTED BY")) 
Example 4
Project: GraphiPy   Author: shobeir   File: twitter_api.py    License: MIT License 6 votes vote down vote up
def fecth_friends_by_screenname(self, graph, screenname, limit=15):
		user = self.get_single_user_by_screenname(graph, screenname)
		graph.create_node(user)

		url = "https://api.twitter.com/1.1/friends/list.json?screen_name=" + screenname + "&count=" + str(limit)
		http = httplib2.Http()
		headers = {
			'Authorization': 'Bearer ' + self.bearer_token
		}
		response, content = http.request(url, method="GET", headers=headers)
		result = json.loads(content.decode())

		for friend in result["users"]:
			single_friend = TwitterUser(friend)
			graph.create_node(single_friend)
			graph.create_edge(Edge(single_friend.get_id(), user.get_id(), "FRIEND WITH"))
			graph.create_edge(Edge(user.get_id(), single_friend.get_id(), "FRIEND WITH")) 
Example 5
Project: GraphiPy   Author: shobeir   File: reddit_api.py    License: MIT License 6 votes vote down vote up
def __init__(self, api):
        self.client_id = api["client_id"]
        self.client_secret = api["client_secret"]
        self.user_agent = api["user_agent"]

        self.h = httplib2.Http(".cache")
        self.h.add_credentials(self.client_id, self.client_secret)
        resp, content = self.h.request(
            "https://www.reddit.com/api/v1/access_token/?grant_type=password&username=" +
            api["username"]+"&password="+api["password"],
            "POST"
        )

        content = json.loads(content.decode("utf-8"))

        self.headers = {
            "Authorization": "bearer " + content["access_token"],
            "User-Agent": self.user_agent
        } 
Example 6
Project: GraphiPy   Author: shobeir   File: pinterest_api.py    License: MIT License 6 votes vote down vote up
def fetch_pinterest_my_boards(self, graph):
        url = "https://api.pinterest.com/v1/me/?access_token=" + self.access_token + \
            "&fields=first_name%2Cid%2Clast_name%2Curl%2Cbio%2Caccount_type%2Ccounts%2Ccreated_at%2Cimage%2Cusername"
        http = httplib2.Http()
        response, content = http.request(url, method="GET")
        result = json.loads(content.decode())
        user = PinterestUser(result["data"])
        graph.create_node(user)

        url = "https://api.pinterest.com/v1/me/boards/?access_token=" + self.access_token + \
            "&fields=id%2Cname%2Curl%2Ccounts%2Ccreated_at%2Ccreator%2Cdescription%2Cimage%2Cprivacy"
        http = httplib2.Http()
        response, content = http.request(url, method="GET")
        result = json.loads(content.decode())

        for myboard in result["data"]:
            board = PinterestBoard(myboard)
            graph.create_node(board)
            graph.create_edge(Edge(board.get_id(), user.get_id(), "CREATED_BY"))
            graph.create_edge(Edge(user.get_id(), board.get_id(), "CREATED"))



    # get the graph of my pins 
Example 7
Project: GraphiPy   Author: shobeir   File: pinterest_api.py    License: MIT License 6 votes vote down vote up
def fetch_pinterest_my_pins(self, graph):
        url = "https://api.pinterest.com/v1/me/?access_token=" + self.access_token + \
            "&fields=first_name%2Cid%2Clast_name%2Curl%2Cbio%2Caccount_type%2Ccounts%2Ccreated_at%2Cimage%2Cusername"
        http = httplib2.Http()
        response, content = http.request(url, method="GET")
        result = json.loads(content.decode())
        user = PinterestUser(result["data"])
        graph.create_node(user)

        url = "https://api.pinterest.com/v1/me/pins/?access_token=" + self.access_token + \
            "&fields=id%2Clink%2Cnote%2Curl%2Cattribution%2Cboard%2Ccolor%2Coriginal_link%2Ccounts%2Ccreated_at%2Ccreator%2Cimage%2Cmedia"
        http = httplib2.Http()
        response, content = http.request(url, method="GET")
        result = json.loads(content.decode())

        for mypin in result["data"]:
            pin = PinterestPin(mypin)
            graph.create_node(pin)
            graph.create_edge(Edge(pin.get_id(), user.get_id(), "CREATED_BY"))
            graph.create_edge(Edge(user.get_id(), pin.get_id(), "CREATED"))



    # get the graph of my followers 
Example 8
Project: GraphiPy   Author: shobeir   File: pinterest_api.py    License: MIT License 6 votes vote down vote up
def fetch_pinterest_my_followers(self, graph):
        url = "https://api.pinterest.com/v1/me/?access_token=" + self.access_token + \
            "&fields=first_name%2Cid%2Clast_name%2Curl%2Caccount_type%2Cusername%2Cbio%2Ccounts%2Ccreated_at%2Cimage"
        http = httplib2.Http()
        response, content = http.request(url, method="GET")
        result = json.loads(content.decode())
        user = PinterestUser(result["data"])
        graph.create_node(user)

        url = "https://api.pinterest.com/v1/me/followers/?access_token=" + self.access_token + \
            "&fields=first_name%2Cid%2Clast_name%2Curl%2Caccount_type%2Cusername%2Cbio%2Ccounts%2Ccreated_at%2Cimage"
        http = httplib2.Http()
        response, content = http.request(url, method="GET")
        result = json.loads(content.decode())

        for myfollower in result["data"]:
            follower = PinterestUser(myfollower)
            graph.create_node(follower)
            graph.create_edge(Edge(user.get_id(), follower.get_id(), "FOLLOWED_BY"))



    # get the graph of my following users 
Example 9
Project: GraphiPy   Author: shobeir   File: pinterest_api.py    License: MIT License 6 votes vote down vote up
def fetch_pinterest_my_following_users(self, graph):
        url = "https://api.pinterest.com/v1/me/?access_token=" + self.access_token + \
            "&fields=first_name%2Cid%2Clast_name%2Curl%2Caccount_type%2Cusername%2Cbio%2Ccounts%2Ccreated_at%2Cimage"
        http = httplib2.Http()
        response, content = http.request(url, method="GET")
        result = json.loads(content.decode())
        user = PinterestUser(result["data"])
        graph.create_node(user)

        url = "https://api.pinterest.com/v1/me/following/users/?access_token=" + self.access_token + \
            "&fields=first_name%2Cid%2Clast_name%2Curl%2Caccount_type%2Cusername%2Cbio%2Ccounts%2Ccreated_at%2Cimage"
        http = httplib2.Http()
        response, content = http.request(url, method="GET")
        result = json.loads(content.decode())

        for myfollowing in result["data"]:
            following = PinterestUser(myfollowing)
            graph.create_node(following)
            graph.create_edge(Edge(user.get_id(), following.get_id(), "FOLLOWING"))



    # get the graph of my following boards 
Example 10
Project: avrae   Author: avrae   File: gsheet.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _refresh_google_token():
        with GoogleSheet._client_lock():
            def _():
                import httplib2

                http = httplib2.Http()
                GoogleSheet.g_client.auth.refresh(http)
                GoogleSheet.g_client.session.headers.update({
                    'Authorization': 'Bearer %s' % GoogleSheet.g_client.auth.access_token
                })

            try:
                await asyncio.get_event_loop().run_in_executor(None, _)
            except:
                GoogleSheet._client_initializing = False
                raise
        log.info("Refreshed google token") 
Example 11
Project: iris-relay   Author: linkedin   File: gmail.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def __init__(self, config=None, proxy_config=None):
        self.config = config
        self.client = None
        if proxy_config and 'host' in proxy_config and 'port' in proxy_config:
            proxy_info = ProxyInfo(socks.PROXY_TYPE_HTTP_NO_TUNNEL,
                                   proxy_config['host'], proxy_config['port'])
        else:
            proxy_info = None
        self.http = Http(proxy_info=proxy_info)
        self.var_dir = self.config['var_dir']
        if not exists(self.var_dir):
            makedirs(self.var_dir)
        self.history_id_f = join(self.var_dir, 'gmail_last_history_id')
        if exists(self.history_id_f):
            with open(self.history_id_f) as fh:
                logger.info('Loaded last gmail history id %d', int(fh.read()))
        else:
            # store an invalid id, which will get renewed on next push event
            self.save_last_history_id('1') 
Example 12
Project: edx2bigquery   Author: mitodl   File: auth.py    License: GNU General Public License v2.0 6 votes vote down vote up
def get_oauth2_creds():
  '''Generates user credentials.
  
  Will prompt the user to authorize the client when run the first time.
  Saves the credentials in ~/bigquery_credentials.dat.
  '''
  flow  = flow_from_clientsecrets('edx2bigquery-client-key.json',
                                  scope=BIGQUERY_SCOPE)
  storage = Storage(os.path.expanduser('~/bigquery_credentials.dat'))
  credentials = storage.get()
  if credentials is None or credentials.invalid:
    flags = tools.argparser.parse_args([])
    credentials = tools.run_flow(flow, storage, flags)
  else:
    # Make sure we have an up-to-date copy of the creds.
    credentials.refresh(httplib2.Http())
  return credentials 
Example 13
Project: rekall   Author: google   File: cloud.py    License: GNU General Public License v2.0 6 votes vote down vote up
def oauth_token(self):
        # The google api and oauth2client libraries use httplib2 instead of
        # requests. Unfortunately httplib2 is terrible (not thread safe, no
        # streaming interface) so we just grab the access_token from the
        # credentials object and use it directly in the requests library anyway.
        max_lifetime = (service_account_module.ServiceAccountCredentials.
                        MAX_TOKEN_LIFETIME_SECS)

        # Refresh token at least this often.
        if (self._oauth_token is None or
            self._oauth_token_age < time.time() - max_lifetime / 2):
            credentials = (service_account_module.
                           ServiceAccountCredentials.
                           from_json_keyfile_dict(
                               self.to_primitive(False),
                               scopes=self._scopes))

            # Its ok to use httplib2 just for refreshing the tokens.
            http = httplib2.Http()
            credentials.refresh(http)

            self._oauth_token = credentials.access_token
            self._oauth_token_age = time.time()

        return self._oauth_token 
Example 14
Project: earthengine   Author: mortcanty   File: appengine.py    License: MIT License 6 votes vote down vote up
def _refresh(self, http_request):
    """Refreshes the access_token.

    Since the underlying App Engine app_identity implementation does its own
    caching we can skip all the storage hoops and just to a refresh using the
    API.

    Args:
      http_request: callable, a callable that matches the method signature of
        httplib2.Http.request, used to make the refresh request.

    Raises:
      AccessTokenRefreshError: When the refresh fails.
    """
    try:
      scopes = self.scope.split()
      (token, _) = app_identity.get_access_token(
          scopes, service_account_id=self.service_account_id)
    except app_identity.Error as e:
      raise AccessTokenRefreshError(str(e))
    self.access_token = token 
Example 15
Project: cf-mendix-buildpack   Author: mendix   File: client.py    License: Apache License 2.0 6 votes vote down vote up
def request(self, action, params=None, timeout=None):
        body = {"action": action}
        if params:
            body["params"] = params
        body = json.dumps(body)
        h = httplib2.Http(
            timeout=timeout, proxy_info=None
        )  # httplib does not like os.fork
        logger.trace("M2EE request body: %s" % body)
        (response_headers, response_body) = h.request(
            self._url, "POST", body, headers=self._headers
        )
        if response_headers["status"] == "200":
            logger.trace("M2EE response: %s" % response_body)
            return M2EEResponse(
                action, json.loads(response_body.decode("utf-8"))
            )
        else:
            logger.error(
                "non-200 http status code: %s %s"
                % (response_headers, response_body)
            ) 
Example 16
Project: deezer-bigquery   Author: apassant   File: bigquery.py    License: MIT License 6 votes vote down vote up
def build_service(secret, credentials):
    """
    Build reference to a BigQuery service / API.
    
    Parameters
    ----------
    secret : string
        Path to the secret files
    credentials : string
        Path to the credentials files

    Returns
    -------
    out : object
        The service reference
    """
    flow = flow_from_clientsecrets(secret, scope="https://www.googleapis.com/auth/bigquery")
    storage = Storage(credentials)
    credentials = storage.get()

    if credentials is None or credentials.invalid:
        credentials = tools.run_flow(flow, storage, tools.argparser.parse_args([]))

    http = credentials.authorize(httplib2.Http())
    return build("bigquery", "v2", http=http) 
Example 17
Project: pyconjpbot   Author: pyconjp   File: google_api.py    License: MIT License 6 votes vote down vote up
def main():
    credentials = get_credentials()
    http = credentials.authorize(httplib2.Http())
    service = discovery.build('calendar', 'v3', http=http)

    now = datetime.utcnow().isoformat() + 'Z'  # 'Z' indicates UTC time
    print('直近の5件のイベントを表示')
    eventsResult = service.events().list(
        calendarId='primary', timeMin=now, maxResults=5, singleEvents=True,
        orderBy='startTime').execute()
    events = eventsResult.get('items', [])

    if not events:
        print('No upcoming events found.')
    for event in events:
        start = event['start'].get('dateTime', event['start'].get('date'))
        print(start, event['summary']) 
Example 18
Project: splunk-ref-pas-code   Author: splunk   File: appengine.py    License: Apache License 2.0 6 votes vote down vote up
def _refresh(self, http_request):
    """Refreshes the access_token.

    Since the underlying App Engine app_identity implementation does its own
    caching we can skip all the storage hoops and just to a refresh using the
    API.

    Args:
      http_request: callable, a callable that matches the method signature of
        httplib2.Http.request, used to make the refresh request.

    Raises:
      AccessTokenRefreshError: When the refresh fails.
    """
    try:
      scopes = self.scope.split()
      (token, _) = app_identity.get_access_token(scopes)
    except app_identity.Error, e:
      raise AccessTokenRefreshError(str(e)) 
Example 19
Project: fitbit-googlefit   Author: praveendath92   File: helpers.py    License: GNU General Public License v3.0 5 votes vote down vote up
def GetGoogleClient(self):
		"""Returns an authenticated google fit client object"""
		logging.debug("Creating Google client")
		credentials = Storage(self.googleCredsFile).get()
		http = credentials.authorize(httplib2.Http())
		client = build('fitness', 'v1', http=http)
		logging.debug("Google client created")
		return client 
Example 20
Project: misp42splunk   Author: remg427   File: http.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def _build_http_connection(
            proxy_info=None,
            timeout=defaults.timeout,
            disable_ssl_cert_validation=defaults.disable_ssl_cert_validation):
        return Http(
            proxy_info=proxy_info,
            timeout=timeout,
            disable_ssl_certificate_validation=disable_ssl_cert_validation) 
Example 21
Project: misp42splunk   Author: remg427   File: http.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def _build_http_connection(
            proxy_info=None,
            timeout=defaults.timeout,
            disable_ssl_cert_validation=defaults.disable_ssl_cert_validation):
        return Http(
            proxy_info=proxy_info,
            timeout=timeout,
            disable_ssl_certificate_validation=disable_ssl_cert_validation) 
Example 22
Project: tox   Author: tox-dev   File: notify.py    License: MIT License 5 votes vote down vote up
def send_mail_message(subject, content):
    this_dir = Path(__file__).parent
    store = file.Storage("credentials.json")
    credentials = store.get()
    if not credentials or credentials.invalid:
        client_secret_json = json.loads((this_dir / "client_secret.json").read_text())
        client_secret_json["installed"]["client_secret"] = os.environ["TOX_DEV_GOOGLE_SECRET"]
        with tempfile.NamedTemporaryFile(mode="w+t") as temp_filename:
            json.dump(client_secret_json, temp_filename)
            temp_filename.flush()
            flow = client.flow_from_clientsecrets(
                filename=temp_filename.name, scope="https://www.googleapis.com/auth/gmail.send",
            )
            credentials = tools.run_flow(flow, store)
    service = discovery.build("gmail", "v1", http=credentials.authorize(httplib2.Http()))

    message = MIMEMultipart("alternative")
    message["Subject"] = subject
    message["From"] = "toxdevorg@gmail.com"
    recipients = ["testing-in-python@lists.idyll.org", "tox-dev@python.org"]
    message["To"] = ", ".join(recipients)
    message.attach(MIMEText(content, "plain"))
    raw_message_no_attachment = base64.urlsafe_b64encode(message.as_bytes())
    raw_message_no_attachment = raw_message_no_attachment.decode()
    body = {"raw": raw_message_no_attachment}
    message_sent = service.users().messages().send(userId="me", body=body).execute()
    message_id = message_sent["id"]
    print(f"\tMessage sent with id: {message_id}") 
Example 23
Project: Zoom2Youtube   Author: Welltory   File: youtube.py    License: MIT License 5 votes vote down vote up
def get_authenticated_service(self):
        """ Create youtube oauth2 connection """
        credentials = AccessTokenCredentials(
            access_token=self.get_auth_code(),
            user_agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
        )
        return build(
            'youtube', 'v3', http=credentials.authorize(httplib2.Http())
        ) 
Example 24
def upload(title, description, tags, thumbnailpath, filepath, time_to_upload):
    credentials = get_credentials()
    http = credentials.authorize(httplib2.Http())
    try:#checkcall
        p = subprocess.check_call([settings.python27_location,
                   "%s\\__main__.py" % settings.youtube_upload_location,
                   "--title=%s" % title,
                   "--description=%s" % description,
                   "--category=Entertainment",
                   "--thumbnail=%s"% thumbnailpath,
                   "--tags=%s" % tags,
                   #"--default-language=\"en\"",
                   #"--embeddable=True",
                   "--publish-at=%s" % time_to_upload,
                   "--privacy=private",
                   #"--default-audio-language=\"en\"",
                   "--credentials-file=%s" % settings.google_cred_upload_creds,
                   "--client-secrets=%s" % settings.google_cred_upload,
                   "%s" % filepath], stderr=STDOUT)

    except subprocess.CalledProcessError as e:
        print("Error Occured Uploading Video")
        if e.returncode == 3:
            print("Out of quotes")
        return False
        #print(output)
    # "--thumbnail=%s" % settings.upload_path + thumbnailpath,

    print("successfully finished uploading video")
    return True 
Example 25
Project: qgis-cartodb   Author: gkudos   File: cartodb.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, api_key, cartodb_domain, host='carto.com', protocol='https', proxy_info=None, *args, **kwargs):
        super(CartoDBAPIKey, self).__init__(cartodb_domain, host, protocol, *args, **kwargs)
        self.api_key = api_key

        certificate_location = certifi.where()
        self.client = httplib2.Http(ca_certs=certificate_location)

        if protocol != 'https':
            warnings.warn("you are using API key auth method with http") 
Example 26
Project: qgis-cartodb   Author: gkudos   File: __init__.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, consumer, token=None, cache=None, timeout=None,
        proxy_info=None):

        if consumer is not None and not isinstance(consumer, Consumer):
            raise ValueError("Invalid consumer.")

        if token is not None and not isinstance(token, Token):
            raise ValueError("Invalid token.")

        self.consumer = consumer
        self.token = token
        self.method = SignatureMethod_HMAC_SHA1()

        httplib2.Http.__init__(self, cache=cache, timeout=timeout, proxy_info=proxy_info) 
Example 27
Project: shoogle   Author: tokland   File: execute.py    License: GNU General Public License v3.0 5 votes vote down vote up
def build_service(service_id, credentials):
    """Return service object from ID and credentials."""
    base_http = httplib2.Http()
    http = (credentials.authorize(base_http) if credentials else base_http)
    service_name, version = service_id.split(":", 1)
    return googleapiclient.discovery.build(service_name, version, http=http) 
Example 28
Project: shoogle   Author: tokland   File: common.py    License: GNU General Public License v3.0 5 votes vote down vote up
def download(url):
    """
    Return the content of a URL if the HTTP_STATUS is 2XX, otherwise raise
    a ShoogleException with a description of the problem.
    """
    logger.info("GET {}".format(url))
    http = httplib2.Http(cache=config.cache_dir)
    headers, content = http.request(url, "GET")
    if re.match("2..", str(headers.status)):
        return content.decode('utf-8')
    else:
        raise ShoogleException("GET {} ({})".format(url, headers.status)) 
Example 29
Project: GraphiPy   Author: shobeir   File: linkedin_api.py    License: MIT License 5 votes vote down vote up
def get_self_info(self):
        """
        This method queries for the user profile
        :return: profile json
        """
        url =  "https://api.linkedin.com/v1/people/~:(" \
               "id," \
               "first-name," \
               "last-name," \
               "maiden-name," \
               "formatted-name," \
               "phonetic-first-name," \
               "phonetic-last-name," \
               "formatted-phonetic-name," \
               "picture-url," \
               "headline," \
               "location," \
               "industry," \
               "num-connections," \
               "current-share," \
               "num-connections-capped," \
               "summary," \
               "specialties," \
               "positions" \
               ")?format=json"
        http = httplib2.Http()
        headers = {"Host": "api.linkedin.com",
                   "Connection": "Keep-Alive",
                   "Authorization": self.access_token}
        response, content = http.request(url, method="GET", headers=headers)
        result = json.loads(content.decode())
        return result 
Example 30
Project: GraphiPy   Author: shobeir   File: twitter_api.py    License: MIT License 5 votes vote down vote up
def get_single_user_by_screenname(self, graph, screenname):
		url = "https://api.twitter.com/1.1/users/show.json?screen_name=" + screenname
		http = httplib2.Http()
		headers = {
			'Authorization': 'Bearer ' + self.bearer_token
		}
		response, content = http.request(url, method="GET", headers=headers)
		result = json.loads(content.decode())
		user = TwitterUser(result)
		return user