def post_as_app(self, profile_id, message, attachment=None):
     attachment=attachment or {}
     graph=GraphAPI()
     graph.fetch_app_access_token()
     try:
         graph.put_wall_post(message, profile_id=str(profile_id), attachment=attachment)
     except GraphAPIError, e:
         logger.error('Problem posting FB: %s' % e)
 def put_like(self, access_token, what_to_like):
     if not self.fb_objects_ids:
         logger.debug('Not posting any FB pages - not configured')
         return
     graph=GraphAPI(access_token=access_token)
     try:
         graph.put_like(str(what_to_like))
     except GraphAPIError, e:
         logger.error('Problem putting like %s -> %s FB: %s' % 
             (access_token, what_to_like, e))
    def post_pages(self, message, attachment=None):
            '''
            https://developers.facebook.com/docs/howtos/login/login-as-page/
            '''

            if not self.fb_objects_ids:
                logger.debug('Not posting any FB pages - not configured')
                return
            attachment=attachment or {}
            for (fbobj_id, access_token) in self.fb_objects_ids:
                graph=GraphAPI(access_token=access_token)
                try:
                    graph.put_wall_post(message, profile_id=str(fbobj_id), attachment=attachment)
                except GraphAPIError, e:
                    logger.error('Problem posting FB: %s' % e)
Example #4
0
def fb_extend_access_token(access_token):
    graph=GraphAPI()
    new_token=graph.extend_access_token(access_token, 
        settings.FACEBOOK_APP_ID, settings.FACEBOOK_APP_SECRET)
    return new_token