def getLongLivedAccessToken(params):
    """ Get long lived access token
	
	API Endpoint:
		https://graph.facebook.com/{graph-api-version}/oauth/access_token?grant_type=fb_exchange_token&client_id={app-id}&client_secret={app-secret}&fb_exchange_token={your-access-token}

	Returns:
		object: data from the endpoint

	"""

    endpointParams = dict()  # parameter to send to the endpoint
    endpointParams[
        'grant_type'] = 'fb_exchange_token'  # tell facebook we want to exchange token
    endpointParams['client_id'] = params[
        'client_id']  # client id from facebook app
    endpointParams['client_secret'] = params[
        'client_secret']  # client secret from facebook app
    endpointParams['fb_exchange_token'] = params[
        'access_token']  # access token to get exchange for a long lived token

    url = params['endpoint_base'] + 'oauth/access_token'  # endpoint url

    return makeApiCall(url, endpointParams,
                       params['debug'])  # make the api call
Exemplo n.º 2
0
    def getUserMedia(params, ig_username, pagingUrl=''):
        """ Get users media

        API Endpoint:
            https://graph.facebook.com/{graph-api-version}/{ig-user-id}/media?fields={fields}&access_token={access-token}

            GET graph.facebook.com/[YOUR-IG-BUSINESS-ACCOUNT-ID]?fields=business_discovery.username(USERNAME){media{caption,media_url,media_type,like_count,comments_count,id}}
        Returns:
            object: data from the endpoint
        """

        endpointParams = dict()  # parameter to send to the endpoint
        endpointParams[
            'fields'] = 'business_discovery.username(' + ig_username + '){media{timestamp,caption,media_url,media_type,like_count,comments_count,id}}'  # string of fields to get back with the request for the account

        # endpointParams['fields'] = 'id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,username,like_count,comments_count' # fields to get back
        endpointParams['access_token'] = params['access_token']  # access token

        if ('' == pagingUrl):  # get first page
            url = params['endpoint_base'] + params['instagram_account_id']
        else:  # get specific page
            url = params['endpoint_base'] + params['instagram_account_id']
            endpointParams['after'] = pagingUrl
            # url = params['endpoint_base'] + params['instagram_account_id'] + pagingUrl  # endpoint url

        return makeApiCall(url, endpointParams,
                           params['debug'])  # make the api call
Exemplo n.º 3
0
def getUserInsights(params,
                    period='day',
                    metric='follower_count,impressions,profile_views,reach',
                    datetime_end=datetime.datetime.now()):
    """ Get insights for a users account
	
	API Endpoint:
		https://graph.facebook.com/{graph-api-version}/{ig-user-id}/insights?metric={metric}&period={period}

	Returns:
		object: data from the endpoint

	"""

    datetime_end = datetime_end
    datetime_begin = datetime_end + datetime.timedelta(days=-30)

    endpointParams = dict()  # parameter to send to the endpoint
    endpointParams['metric'] = metric  # fields to get back
    endpointParams['period'] = period  # period of analysis
    if period == 'day':
        endpointParams['since'] = int(datetime_begin.timestamp())  # first date
        endpointParams['until'] = int(datetime_end.timestamp())  # last date
    endpointParams['access_token'] = params['access_token']  # access token

    url = params['endpoint_base'] + params[
        'instagram_account_id'] + '/insights'  # endpoint url

    return makeApiCall(url, endpointParams,
                       params['debug'])  # make the api call
Exemplo n.º 4
0
def debugAccessToken(params):
    endpointParams = dict()
    endpointParams['input_token'] = params['access_token']
    endpointParams['access_token'] = params['access_token']

    url = params['graph_domain'] + '/debug_token'

    return makeApiCall(url, endpointParams, params['debug'])
Exemplo n.º 5
0
def getPageId(params):

    endpointParams = dict()
    endpointParams['access_token'] = params['access_token']

    url = params['endpoint_base'] + 'me/accounts'

    return makeApiCall(url, endpointParams, params['debug'])
Exemplo n.º 6
0
def getUserStories(params):
	endpointParams = dict()
 	endpointParams['fields'] = 'id, caption, media_type, media_url, permalink,\
 	thumbnail_url, timestamp, username'
 	endpointParams['access_token'] = params['access_token']

 	url = params['endpoint_base'] + params['instagram_id'] + '/stories'

 	return makeApiCall(url, endpointParams, params['debug'])
def getIgAccountId(params):

	endpointParams = dict()
	endpointParams['fields'] = 'instagram_business_account'
	endpointParams['access_token'] = params['access_token']

	url = params['endpoint_base'] + params['page_id']

	return makeApiCall(url, endpointParams, params['debug'])
Exemplo n.º 8
0
def getInstagramAccount(params):

    endpointParams = dict()  #
    endpointParams['access_token'] = params['access_token']
    endpointParams['fields'] = 'instagram_business_account'

    url = params['endpoint_base'] + params['page_id']

    return makeApiCall(url, endpointParams, params['debug'])  # api çağrısı yap
Exemplo n.º 9
0
def getMediaInsights(params):

    endpointParams = dict()
    endpointParams['metric'] = params['metric']
    endpointParams['access_token'] = params['access_token']

    url = params['endpoint_base'] + params['latest_media_id'] + '/insights'

    return makeApiCall(url, endpointParams, params['debug'])
Exemplo n.º 10
0
def debugAccessToken( params ) :

	endpointParams = dict() # endpoint'e gönderilicek parametreler
	endpointParams['input_token'] = params['access_token'] # access tokenini gir
	endpointParams['access_token'] = params['access_token'] # hata ayıklama bilgilerini almak için access token

	url = params['graph_domain'] + '/debug_token' # endpoint url

	return makeApiCall( url, endpointParams, params['debug'] ) #api çağrısı döndür
Exemplo n.º 11
0
def getUsersMedia( params ) :

	endpointParams = dict()
	endpointParams['fields'] = 'id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,username,comments_count,like_count'
	endpointParams['access_token'] = params['access_token']

	url = params['endpoint_base'] + params['instagram_account_id'] + '/media'

	return makeApiCall( url, endpointParams, params['debug'] )
Exemplo n.º 12
0
def getAccountInfo( params ) :

	endpointParams = dict()
	endpointParams['fields'] = 'business_discovery.username('+ params['ig_username'] +'){username,website,name,ig_id,id,profile_picture_url,biography,follows_count,followers_count,media_count,media }'
	endpointParams['access_token'] = params['access_token']

	url = params['endpoint_base'] + '/' + params['instagram_account_id']

	return makeApiCall( url, endpointParams, params['debug'] )
Exemplo n.º 13
0
def debugAccessToken( params ) :

	endpointParams = dict() # parameter to send to the endpoint
	endpointParams['input_token'] = params['access_token'] # input token is the access token
	endpointParams['access_token'] = params['access_token'] # access token to get debug info on

	url = params['graph_domain'] + '/debug_token' # endpoint url

	return makeApiCall( url, endpointParams, params['debug'] ) # make the api call
Exemplo n.º 14
0
def getUserPages(params):

    endpointParams = dict()  # parameter to send to the endpoint
    endpointParams['access_token'] = params['access_token']  # access token

    url = params['endpoint_base'] + 'me/accounts'  # endpoint url

    return makeApiCall(url, endpointParams,
                       params['debug'])  # make the api call
                    def getHashtagInfo( params ) :
                        endpointParams = dict() # endpoint'e gönderilicek parametreler
                        endpointParams['user_id'] = params['instagram_account_id'] # istek yapılan kullanıcı id'si
                        endpointParams['q'] = ig_hashtag # hashtag ismi
                        endpointParams['fields'] = 'id,name' # geri alınacak alanlar
                        endpointParams['access_token'] = params['access_token'] # access token

                        url = params['endpoint_base'] + 'ig_hashtag_search' # endpoint url

                        return makeApiCall( url, endpointParams, params['debug'] )
Exemplo n.º 16
0
                    def getHashtagInfo( params ) :
                        endpointParams = dict() # parameter to send to the endpoint
                        endpointParams['user_id'] = params['instagram_account_id'] # user id making request
                        endpointParams['q'] = ig_hashtag # hashtag name
                        endpointParams['fields'] = 'id,name' # fields to get back
                        endpointParams['access_token'] = params['access_token'] # access token

                        url = params['endpoint_base'] + 'ig_hashtag_search' # endpoint url

                        return makeApiCall( url, endpointParams, params['debug'] )
def getUserInsight(params):

	endpointParams = dict()
 	endpointParams['metric'] = 'audience_city , audience_country, audience_gender_age, audience_locale'
 	endpointParams['period'] = 'lifetime'
 	endpointParams['access_token'] = params['access_token']

 	url = params['endpoint_base'] + params['instagram_id'] + '/insights' 
 
 	return makeApiCall(url, endpointParams, params['debug'])
Exemplo n.º 18
0
def getUserInsights(params):

    endpointParams = dict()
    endpointParams['metric'] = 'follower_count,impressions,profile_views,reach'
    endpointParams['period'] = 'day'
    endpointParams['access_token'] = params['access_token']

    url = params['endpoint_base'] + params['instagram_account_id'] + '/insights'

    return makeApiCall(url, endpointParams, params['debug'])
def getInstagramAccount(params):

    endpointParams = dict()  # parameter to send to the endpoint
    endpointParams['access_token'] = params[
        'access_token']  # tell facebook we want to exchange token
    endpointParams['fields'] = 'instagram_business_account'  # access token

    url = params['endpoint_base'] + params['page_id']  # endpoint url

    return makeApiCall(url, endpointParams,
                       params['debug'])  # make the api call
def getLongLivedAccessToken( params ) :

	endpointParams = dict() # parameter to send to the endpoint
	endpointParams['grant_type'] = 'fb_exchange_token' # tell facebook we want to exchange token
	endpointParams['client_id'] = params['client_id'] # client id from facebook app
	endpointParams['client_secret'] = params['client_secret'] # client secret from facebook app
	endpointParams['fb_exchange_token'] = params['access_token'] # access token to get exchange for a long lived token

	url = params['endpoint_base'] + 'oauth/access_token?' # endpoint url

	return makeApiCall( url, endpointParams, params['debug'] ) # make the api call
def getLongLivedAccessToken(params):

    endpointParams = dict()
    endpointParams['grant_type'] = 'fb_exchange_token'
    endpointParams['client_id'] = params['client_id']
    endpointParams['client_secret'] = params['client_secret']
    endpointParams['fb_exchange_token'] = params['access_token']

    url = params['endpoint_base'] + 'oauth/access_token'

    return makeApiCall(url, endpointParams, params['debug'])
Exemplo n.º 22
0
def getUserMedia(
        params):  #method returns user media objects (photo/video posts)

    endpointParams = dict()
    endpointParams['fields'] = 'id, caption, media_type, media_url, permalink,\
 	thumbnail_url, timestamp, username, comments_count'

    endpointParams['access_token'] = params['access_token']

    url = params['endpoint_base'] + params['instagram_id'] + '/media'

    return makeApiCall(url, endpointParams, params['debug'])
Exemplo n.º 23
0
def getLongLivedAccessToken(params):

    endpointParams = dict()
    endpointParams['grant_type'] = 'fb_exchange_token'
    endpointParams['client_id'] = params['client_id']
    endpointParams['client_secret'] = params['client_secret']
    endpointParams['fb_exchange_token'] = params[
        'access_token']  # access tokeni uzun ömürlü tokenle değiştir

    url = params['endpoint_base'] + 'oauth/access_token?'  # son url

    return makeApiCall(url, endpointParams, params['debug'])  # api çağrısı yap
            def getAccountInfo(params):

                endpointParams = dict()  # parameter to send to the endpoint
                endpointParams[
                    'fields'] = 'business_discovery.username(' + ig_username + '){id,name,follows_count,followers_count,media_count,website,profile_picture_url,biography}'  # string of fields to get back with the request for the account
                endpointParams['access_token'] = params[
                    'access_token']  # access token

                url = params['endpoint_base'] + params[
                    'instagram_account_id']  # endpoint url

                return makeApiCall(url, endpointParams,
                                   params['debug'])  # make the api call
Exemplo n.º 25
0
def getInstagramUserMedia(params):
    """ Get instagram users's media

    API Endpoint:
            https://graph.facebook.com/{graph-api-version}/{ig-user-id}/media?access_token={your-access-token}
    """

    endpointParams = dict()
    endpointParams['access_token'] = params['access_token']

    url = params['endpoint_base'] + params['instagram_account_id'] + '/media'

    return makeApiCall(url, endpointParams, params['debug'])
def getInstagramMediaComment(params):
    """ Get instagram users's media

    API Endpoint:
            https://graph.facebook.com/{graph-api-version}/{ig-media-id}/comments?access_token={your-access-token}
    """
    
    endpointParams = dict()
    endpointParams['access_token'] = params['access_token']

    url = params['endpoint_base'] + params['ga_media_id'] + '/comments'

    return makeApiCall(url, endpointParams, params['debug'])   
Exemplo n.º 27
0
def getInstagramAccount(params):
    """ Get instagram account
    
    API Endpoint:
            https://graph.facebook.com/{graph-api-version}/{page-id}?access_token={your-access-token}&fields=instagram_business_account
    Returns:
            object: data from the endpoint
    """
    endpointParams = dict()
    endpointParams['access_token'] = params['access_token']
    endpointParams['fields'] = 'instagram_business_account'

    url = params['endpoint_base'] + params['page_id']

    return makeApiCall(url, endpointParams, params['debug'])
Exemplo n.º 28
0
def getCommentInfo(params, commentID):
    """ Get instagram media commentator's username

    API Endpoint:
            https://graph.facebook.com/{graph-api-version}/{ig-comment-id}?
            fields={fields}&access_token={your-access-token}
    """

    endpointParams = dict()
    endpointParams['access_token'] = params['access_token']
    endpointParams['fields'] = 'username,text'

    url = params['endpoint_base'] + '/' + commentID

    return makeApiCall(url, endpointParams, params['debug'])
Exemplo n.º 29
0
def getMediaInsights(params) :
	""" Get insights for a specific media id
	
	API Endpoint:
		https://graph.facebook.com/{graph-api-version}/{ig-media-id}/insights?metric={metric}
	Returns:
		object: data from the endpoint
	"""
	endpointParams = dict() # parameter to send to the endpoint
	endpointParams['metric'] = 'engagement,impressions,reach,saved,video_views'# fields to get back
	endpointParams['access_token'] = params['access_token'] # access token

	url = params['endpoint_base'] + params['post_id'] + '/insights' # endpoint url

	return makeApiCall( url, endpointParams, params['debug'] ) # make the api call
def getUserPages(params):
    """ Get facebook pages for a user

    API Endpoint:
            https://graph.facebook.com/{graph-api-version}/me/accounts?access_token={access-token}
    Returns:
            object: data from the endpoint
    """

    endpointParams = dict()
    endpointParams['access_token'] = params['access_token']

    url = params['endpoint_base'] + 'me/accounts'

    return makeApiCall(url, endpointParams, params['debug'])