Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

amend and specification #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion fixtures/user_recent_media.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,5 @@
"id": "3",
"location": null
}

]
}
6 changes: 3 additions & 3 deletions instagram/bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

re_path_template = re.compile('{\w+}')


#create a function
def encode_string(value):
return value.encode('utf-8') \
if isinstance(value, six.text_type) else str(value)


#create a InstagramClientError class
class InstagramClientError(Exception):
def __init__(self, error_message, status_code=None):
self.status_code = status_code
Expand Down Expand Up @@ -161,7 +161,7 @@ def _do_api_request(self, url, method="GET", body=None, headers=None):
return api_responses, self._build_pagination_info(content_obj)
else:
raise InstagramAPIError(status_code, content_obj['meta']['error_type'], content_obj['meta']['error_message'])

#GET to get list of all resources and information about them
def _paginator_with_url(self, url, method="GET", body=None, headers=None):
headers = headers or {}
pages_read = 0
Expand Down
2 changes: 1 addition & 1 deletion instagram/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _make_subscription_action(method, include=None, exclude=None):
objectify_response=False,
signature=signature,
)

#POST to create new subscription,DELETE to remove subscription,GET to get resources list
create_subscription = _make_subscription_action('POST')
list_subscriptions = _make_subscription_action('GET')
delete_subscriptions = _make_subscription_action('DELETE', exclude=['object_id'], include=['id'])
2 changes: 1 addition & 1 deletion instagram/helper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import calendar
from datetime import datetime


#create two functions
def timestamp_to_datetime(ts):
return datetime.utcfromtimestamp(float(ts))

Expand Down
6 changes: 3 additions & 3 deletions instagram/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .helper import timestamp_to_datetime
import six


#create class
class ApiModel(object):

@classmethod
Expand Down Expand Up @@ -44,12 +44,12 @@ def __unicode__(self):


class Media(ApiModel):

def __init__(self, id=None, **kwargs):
self.id = id
for key, value in six.iteritems(kwargs):
setattr(self, key, value)

#create and define functions
def get_standard_resolution_url(self):
if self.type == 'image':
return self.images['standard_resolution'].url
Expand Down
13 changes: 5 additions & 8 deletions instagram/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def exchange_user_id_for_access_token(self, user_id):
def exchange_xauth_login_for_access_token(self, username, password, scope=None):
""" scope should be a tuple or list of requested scope access levels """
req = OAuth2AuthExchangeRequest(self)
return req.exchange_for_access_token(username=username, password=password,
scope=scope)

return req.exchange_for_access_token(username=username, password=password,scope=scope)

class OAuth2AuthExchangeRequest(object):
def __init__(self, api):
Expand All @@ -72,7 +70,7 @@ def _url_for_authorize(self, scope=None):
client_params.update(scope=' '.join(scope))
url_params = urlencode(client_params)
return "%s?%s" % (self.api.authorize_url, url_params)

#Dict client_params
def _data_for_exchange(self, code=None, username=None, password=None, scope=None, user_id=None):
client_params = {
"client_id": self.api.client_id,
Expand Down Expand Up @@ -115,7 +113,6 @@ def exchange_for_access_token(self, code=None, username=None, password=None, sco
raise OAuth2AuthExchangeError(parsed_content.get("error_message", ""))
return parsed_content['access_token'], parsed_content['user']


class OAuth2Request(object):
def __init__(self, api):
self.api = api
Expand All @@ -128,10 +125,10 @@ def _generate_sig(self, endpoint, params, secret):

def url_for_get(self, path, parameters):
return self._full_url_with_params(path, parameters)

#GET to get list and informations of resources
def get_request(self, path, **kwargs):
return self.make_request(self.prepare_request("GET", path, kwargs))

#POST to create new resources
def post_request(self, path, **kwargs):
return self.make_request(self.prepare_request("POST", path, kwargs))

Expand Down Expand Up @@ -227,7 +224,7 @@ def prepare_request(self, method, path, params, include_secret=False):
url = self._full_url(path)

return url, method, body, headers

#GET used to get information of resource
def make_request(self, url, method="GET", body=None, headers=None):
headers = headers or {}
if not 'User-Agent' in headers:
Expand Down
5 changes: 4 additions & 1 deletion python_instagram.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
setup.py
tests.py
sample_app.py
get_access_token.py
instagram/__init__.py
instagram/bind.py
instagram/client.py
Expand All @@ -12,4 +15,4 @@ python_instagram.egg-info/SOURCES.txt
python_instagram.egg-info/dependency_links.txt
python_instagram.egg-info/requires.txt
python_instagram.egg-info/top_level.txt
python_instagram.egg-info/zip-safe
python_instagram.egg-info/zip-safe
4 changes: 2 additions & 2 deletions sample_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}

app = beaker.middleware.SessionMiddleware(bottle.app(), session_opts)

#Dict the CONFIG
CONFIG = {
'client_id': '<client_id>',
'client_secret': '<client_secret>',
Expand All @@ -30,7 +30,7 @@ def process_tag_update(update):

reactor = subscriptions.SubscriptionsReactor()
reactor.register_callback(subscriptions.SubscriptionType.TAG, process_tag_update)

#Define and access a route for url ending with '/'
@route('/')
def home():
try:
Expand Down
11 changes: 11 additions & 0 deletions specification.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Every new app created on the instagram Platform starts in Sandbox mode.Apps in this mode can use any API endpoint but are restricted to a limited number of users and media.This is great for developing and testing your app.To go Live and fully access Instagram content,you will need to submit your application for review and approval.Once reviewed,you will only be able to request users the Permision Scopes for which your app was approved.Because of this,your application may not be able to use some API endpoints unless the corresponding permissions were reviewed and approved.The review process allows us to ensure an authentic and consistent experience for the Instagram Community.The app review process aims to help community members more granularly control how their content is being shared through 3rd party apps and that those apps are building compliant use case.

Criteria for Review
1.Brand and policy compliance
-App must comply with Instagram Platform Policy and Instagram Brand Guideliness.

2.Submission quality
-Notes must be clear,concise.We will not approve submissions with insufficient notes.

3.Video screencast quality
-The video screencast must show the Instagram login experience of your app,proper credentials and the usage of every permission you are requesting.We will not approve submissions if you do not provide a clear and working screencast.