Example #1
0
def __handle__profile(args):
    require_login()
    profile = fbsh.get_graph_endpoint(ACCESS_TOKEN, "me/feed")
    profile = profile["data"]

    for item in profile:
        __render_feed_item(item)
Example #2
0
def __handle__newsfeed(args):
    require_login()
    newsfeed = fbsh.get_graph_endpoint(ACCESS_TOKEN, "me/home")
    newsfeed = newsfeed["data"]  # ignore paging for now

    for item in newsfeed:
        __render_feed_item(item)
Example #3
0
def __handle__profile(args):
  require_login()
  profile = fbsh.get_graph_endpoint(ACCESS_TOKEN, 'me/feed')
  profile = profile['data']

  for item in profile:
    __render_feed_item(item)
Example #4
0
def __handle__newsfeed(args):
  require_login()
  newsfeed = fbsh.get_graph_endpoint(ACCESS_TOKEN, 'me/home')
  newsfeed = newsfeed['data'] # ignore paging for now

  for item in newsfeed:
    __render_feed_item(item)
Example #5
0
def __handle__login(args):

    while True:
        email = raw_input("Email: ")
        passwd = getpass.getpass()

        try:
            (tok, exp) = fbsh.do_login(email, passwd)
            break
        except fbsh.BadEmailAndPass:
            print "Bad email and/or password"
        except Exception as excp:
            try:
                reason = "unknown error"
                reason = excp.message
                reason = excp.reason
            except AttributeError:
                pass
            print "Error logging in:", reason
            return

    assert tok != None

    ident = fbsh.get_graph_endpoint(tok, "me")
    name = ident["name"]

    global ACCESS_TOKEN, EXPIRES, NAME
    ACCESS_TOKEN = tok
    EXPIRES = time.time() + exp
    NAME = name

    try:
        fp = open(tokenfile, "w")
        fp.write(json.dumps({"access_token": ACCESS_TOKEN, "expires": EXPIRES, "name": NAME}))
        fp.close()
    except IOError as ex:
        pass

    print "Successfully logged in as", name
    assert is_logged_in()
Example #6
0
def __handle__login(args):

  while True:
    email  = raw_input('Email: ')
    passwd = getpass.getpass()

    try:
      (tok, exp) = fbsh.do_login(email, passwd)
      break
    except fbsh.BadEmailAndPass:
      print "Bad email and/or password"
    except Exception as excp:
      try:
        reason = "unknown error"
        reason = excp.message
        reason = excp.reason
      except AttributeError:
        pass
      print "Error logging in:", reason
      return

  assert tok != None

  ident = fbsh.get_graph_endpoint(tok, 'me')
  name  = ident['name']

  global ACCESS_TOKEN, EXPIRES, NAME
  ACCESS_TOKEN = tok
  EXPIRES      = time.time() + exp
  NAME         = name

  try:
    fp = open(tokenfile, 'w')
    fp.write(json.dumps({'access_token':ACCESS_TOKEN,'expires':EXPIRES,'name':NAME}))
    fp.close()
  except IOError as ex:
    pass

  print "Successfully logged in as", name
  assert is_logged_in()