Skip to content

Commit

Permalink
example of introspection usage
Browse files Browse the repository at this point in the history
  • Loading branch information
indeyets committed Jun 14, 2013
1 parent 4bb553b commit 730a580
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/introspection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is free and unencumbered software released into the public domain.
# For more information, please refer to <http://unlicense.org/>
#
# This script uses "requests-oauthlib" library
# For more information, please refer to <https://github.com/requests/requests-oauthlib#installation>
import json
import urllib

import requests
from requests_oauthlib import OAuth1


# CHANGE THESE variables
consumer_token = 'consumer_token'
consumer_secret = 'consumer_secret'
access_token = 'access_token'
access_secret = 'access_secret'
graph_iri = 'http://example.com/graph'


oauth = OAuth1(consumer_token, consumer_secret, access_token, access_secret, signature_type='auth_header')

_predicates = requests.get('https://api.grids.by/v1/predicates.json?%s' % (urllib.urlencode({'graph': graph_iri})), auth=oauth)
predicates = json.loads(_predicates.content)

for predicate in predicates:
print(predicate)

_values = requests.get('https://api.grids.by/v1/values.json?%s' % (urllib.urlencode({'graph': graph_iri, 'predicate': predicate})), auth=oauth)
values = json.loads(_values.content)

for value in values:
print("--> %s" % (value))

0 comments on commit 730a580

Please sign in to comment.