def checkExistence(page): if page != "": try: url = "https://graph.facebook.com/%s" %page conn = urllib2.urlopen(url) resp = conn.read() conn.close() resp = json.deserialize(resp) user_id = resp.get("id","") if len(user_id) >= 12: return True return False except Exception: return False return False
def getRemainingTimeMessage(): acc_tok = Config.objects.all() message = "" if len(acc_tok) > 0: try: acc_tok = acc_tok[0].access_token resp = get("/debug_token", {'input_token': acc_tok, 'access_token':acc_tok}) resp = json.deserialize(resp) if "error" not in resp and "data" in resp and "expires_at" in resp["data"]: expires_at = (int)(resp["data"]["expires_at"]) expires_date = datetime.datetime.fromtimestamp(expires_at) remaining_days = (expires_date - datetime.datetime.now()).days if remaining_days > 0: message = "You have %s day(s) in your current Facebook session." %(remaining_days) else: message = 'You need to renew you Facebook session. Please click on "Renew Facebook Session" below...' except: pass return message