def register():
    user = Facebook()
    db = Database()
    print("|--------------------------------------------------|")
    print("|--------------------REGISTER----------------------|")
    print("|--------------------------------------------------|")
    email = input('\nPlease provide an unique email id to register : ')
    flag = db.exist_user(email)
    if not user.user_exists(email) and flag == None:
        firstName = input("\nPlease enter your first name: ")
        lastName = input("\nPlease enter your last name: ")
        dob = input("\nPlease enter your date of birth: ")
        bio = input("\nPlease enter few lines about yourself: ")
        password = input("\nPlease enter your password: "******"|--------------------------------------------------------------------|"
        )
        print(
            "     You've been successfully signed up! Please login to continue... "
        )
        print(
            "|--------------------------------------------------------------------|"
        )
        print("\n")
    else:
        clear()
        print("|--------------------------|")
        print("    User already exists     ")
        print("|--------------------------|")
        print("\n")
    return
示例#2
0
 def refresh_data(self):
     """Refresh this user's data using the Facebook Graph API"""
     me = Facebook().api(u'/me',
         {u'fields': _USER_FIELDS, u'access_token': self.access_token})
     self.dirty = False
     self.name = me[u'name']
     self.email = me.get(u'email')
     self.picture = me[u'picture']
     self.friends = [user[u'id'] for user in me[u'friends'][u'data']]
     return self.put()
def user_dashboard(current_user):
    db = Database()
    user = Facebook()
    print("|-----------------------------|")
    print("|--------USER DASHBOARD-------|")
    print("|-----------------------------|")
    print('\n What Would You Like To Do?')
    choice = input(
        '\n 1. My Timeline \n 2. My Friends \n 3. My Groups \n 4. My Profile \n 0. Log out \n \n Enter your choice: '
    )
    clear()
    if choice == '1':
        my_timeline(current_user)

    elif choice == '2':
        my_friends(current_user)

    elif choice == '3':
        group_activities(current_user)

    elif choice == '4':
        firstName, lastName, email, dob, bio = db.get_user_node_details(
            current_user)
        clear()
        print("|-------------------------------------------|")
        print("|----------------MY PROFILE-----------------|")
        print("|-------------------------------------------|")
        print(" First Name : ", firstName)
        print(" Last Name : ", lastName)
        print(" Email ID : ", email)
        print(" Date of Birth : ", dob)
        print(" Bio : ", bio)
        print("|-------------------------------------------|")
        input("  Press Enter to go back to your dashboard   ")
        clear()
        user_dashboard(current_user)

    elif choice == '0':
        clear()
        print("|-----------------------------------------|")
        print("     You are logged out of the session     ")
        print("|-----------------------------------------|")
        home_screen()

    else:
        clear()
        print("|-------------------------------------|")
        print("           Invalid Choice!            ")
        print("|-------------------------------------|")
        user_dashboard(current_user)

    return True
示例#4
0
    def __init__(self,config=None):
        '''
        Constructor
        '''
        if config==None:
            with open('apiconfigs.txt', 'rb') as fp:
                config = json.load(fp)
            
        self.twitter=Twitter(config["twitter"])
        self.facebook=Facebook(config["facebook"])
        
        self.twitterMessage=config["twitter"]["message"]
        self.facebookMessage=config["facebook"]["message"]
            
            
        #self.outgoingPath=os.path.join(os.getcwd()+"/outgoing/")
        self.outgoingPath="/tmp/photobooth/outgoing/"

        self.scheduler=sched.scheduler(time.time,time.sleep)
        self.scheduler.enter(2,1,self.upload,())
        
        self.uploadThread = threading.Thread(target=self.scheduler.run)
        self.uploadThread.start()
示例#5
0
def Flogin(mobno,user,password):
  if mobno in loggedin and loggedin[mobno]:
    fb[mobno]=Facebook(mobno)
    if not fb[mobno].connect(user, password):
      db.pushOutboxMsg(mobno, "Invalid facebook user or password! Access Denied!")
    else:
      fb[mobno].start()
      time.sleep(5)
      users=fb[mobno].getOnlineUsers()
      response=""
      for item in users:
	response+="F%s/%s\n" % (item, users[item])
      db.pushOutboxMsg(mobno, response)
  else:
    db.pushOutboxMsg(mobno, "Please login... Reply with LOGIN password to login.")
示例#6
0
    def init_facebook(self):
        """Sets up the request specific Facebook and User instance"""
        facebook = Facebook()
        user = None

        # initial facebook request comes in as a POST with a signed_request
        if u"signed_request" in self.request.POST:
            facebook.load_signed_request(self.request.get("signed_request"))
            # we reset the method to GET because a request from facebook with a
            # signed_request uses POST for security reasons, despite it
            # actually being a GET. in webapp causes loss of request.POST data.
            self.request.method = u"GET"
            self.set_cookie("u", facebook.user_cookie, datetime.timedelta(minutes=1440))
        elif "u" in self.request.cookies:
            facebook.load_signed_request(self.request.cookies.get("u"))

        # try to load or create a user object
        if facebook.user_id:
            user = User.get_by_key_name(facebook.user_id)
            if user:
                # update stored access_token
                if facebook.access_token and facebook.access_token != user.access_token:
                    user.access_token = facebook.access_token
                    user.put()
                # refresh data if we failed in doing so after a realtime ping
                if user.dirty:
                    user.refresh_data()
                # restore stored access_token if necessary
                if not facebook.access_token:
                    facebook.access_token = user.access_token

            if not user and facebook.access_token:
                me = facebook.api(u"/me", {u"fields": User.get_fields()})
                try:
                    friends = [user[u"id"] for user in me[u"friends"][u"data"]]
                    user = User(
                        key_name=facebook.user_id,
                        user_id=facebook.user_id,
                        friends=friends,
                        access_token=facebook.access_token,
                        name=me[u"name"],
                        email=me.get(u"email"),
                        picture=me[u"picture"],
                    )
                    user.put()
                except KeyError, ex:
                    pass  # ignore if can't get the minimum fields
def my_timeline(current_user):
    user = Facebook()
    subchoice = input(
        '\n 1. Display my posts \n 2. Create text post \n 0. Back \n \n Enter your choice: '
    )
    clear()
    if subchoice == '1':
        user.display_user_posts(current_user)
        input("   Press Enter to go back   ")
        clear()
        my_timeline(current_user)
    elif subchoice == '2':
        user.create_post(current_user)
        input("           Press Enter to go back   ")
        clear()
        my_timeline(current_user)
    elif subchoice == '0':
        user_dashboard(current_user)
    else:
        clear()
        print("|-------------------------------------|")
        print("           Invalid Choice!             ")
        print("|-------------------------------------|")
        my_timeline(current_user)
def group_activities(current_user):
    user = Facebook()
    subchoice = input(
        '\n 1. Create new group \n 2. Show groups \n 3. Join group \n 4. Leave group \n 5. My groups \n 6. Post in a group \n 7. Display group posts \n 8. Chat room \n 0. Back \n \n Enter your choice: '
    )
    clear()
    if subchoice == '1':
        user.createGroup(current_user)
        input("           Press Enter to go back   ")
        clear()
        group_activities(current_user)

    elif subchoice == '2':
        user.showGroups()
        input("           Press Enter to go back   ")
        clear()
        group_activities(current_user)

    elif subchoice == '3':
        user.joinGroup(current_user)
        input("           Press Enter to go back   ")
        clear()
        group_activities(current_user)

    elif subchoice == '4':
        user.leaveGroup(current_user)
        input("           Press Enter to go back   ")
        clear()
        group_activities(current_user)

    elif subchoice == '5':
        user.showMyGroups(current_user)
        input("           Press Enter to go back   ")
        clear()
        group_activities(current_user)

    elif subchoice == '6':
        user.post_in_group(current_user)
        input("           Press Enter to go back   ")
        clear()
        group_activities(current_user)

    elif subchoice == '7':
        user.showGroupPosts(current_user)
        input("           Press Enter to go back   ")
        clear()
        group_activities(current_user)

    elif subchoice == '8':
        user.chatRoom(current_user)
        input("           Press Enter to go back   ")
        clear()
        group_activities(current_user)

    elif subchoice == '0':
        user_dashboard(current_user)
    else:
        clear()
        print("|-------------------------------------|")
        print("           Invalid Choice!             ")
        print("|-------------------------------------|")
        group_activities(current_user)
def my_friends(current_user):
    db = Database()
    user = Facebook()
    subchoice = input(
        '\n 1. Add friends \n 2. Display friends \n 3. Display friend\'s posts \n 0. Back \n \n Enter your choice: '
    )
    clear()
    if subchoice == '1':
        user.showUsers()
        friend_name = input(
            "\n Enter the first name of the user you want to add as a friend from the users list: "
        )
        user.addFriend(current_user, friend_name)
        input("           Press Enter to go back   ")
        clear()
        my_friends(current_user)

    elif subchoice == '2':
        user.showFriends(current_user)
        input("           Press Enter to go back   ")
        clear()
        my_friends(current_user)

    elif subchoice == '3':
        user.showFriends(current_user)
        friend_name = input(
            "\n Enter the first name of your friend, to view their posts: ")
        user.showFriendsPost(current_user, friend_name)
        input("           Press Enter to go back   ")
        clear()
        my_friends(current_user)

    elif subchoice == '0':
        user_dashboard(current_user)
    else:
        clear()
        print("|-------------------------------------|")
        print("           Invalid Choice!             ")
        print("|-------------------------------------|")
        my_friends(current_user)
示例#10
0
# -*- coding: utf-8 -*-

import common
from Config import Config
from Facebook import Facebook, Graph

username = Config()['facebook']['username']
password = Config()['facebook']['password']


fb = Facebook()
fb.login(username, password)
token = fb.get_token()
graph = Graph(token)


def test_get_uid():
    assert isinstance(graph.getUID(), int)
	def retrievePhotos(self):
		fb = Facebook(self.user)
		fb.login()
		firstPhotoId = fb.getFirstPhotoId()
		photoSetId = fb.getPhotoSetId()
		fb.downloadPhotos(firstPhotoId, photoSetId)
示例#12
0
class UploadServer(object):
    '''
    classdocs
    '''


    def __init__(self,config=None):
        '''
        Constructor
        '''
        if config==None:
            with open('apiconfigs.txt', 'rb') as fp:
                config = json.load(fp)
            
        self.twitter=Twitter(config["twitter"])
        self.facebook=Facebook(config["facebook"])
        
        self.twitterMessage=config["twitter"]["message"]
        self.facebookMessage=config["facebook"]["message"]
            
            
        #self.outgoingPath=os.path.join(os.getcwd()+"/outgoing/")
        self.outgoingPath="/tmp/photobooth/outgoing/"

        self.scheduler=sched.scheduler(time.time,time.sleep)
        self.scheduler.enter(2,1,self.upload,())
        
        self.uploadThread = threading.Thread(target=self.scheduler.run)
        self.uploadThread.start()
        
    def upload(self):
        for targetFile in glob.glob(os.path.join(self.outgoingPath, '*.done')):
            #print targetFile

            fileName=os.path.basename(targetFile)
            print fileName
            fileTime=datetime.datetime.strptime(fileName[:16], '%Y-%m-%d_%H-%M') 
            print fileTime
            
            
            currentTime=datetime.datetime.now()
            currentTimeString=currentTime.strftime('%Y-%m-%d_%H:%M:%S.%f')
            
            delete=False
            if os.path.isfile(targetFile[:len(targetFile)-5]+".delete"):
                delete=True
            elif (currentTime - fileTime).total_seconds() > 20:
            #if fileTime < datetime.datetime.now()-datetime.timedelta(seconds=20):
                '''then upload'''
                serviceName=fileName[17:len(fileName)-5]
                if(serviceName=="twitter"):
                    print "twitter done file found \nnow uploading"
                    self.twitter.uploadImage(self.twitterMessage+"\ntimestamp: "+currentTimeString,targetFile[:len(targetFile)-5]+".PNG")
                    print "done"
                elif(serviceName=="facebook"):
                    print "facebook done file found\nnow uploading"
                    self.facebook.uploadImage(self.facebookMessage+"\ntimestamp: "+currentTimeString,targetFile[:len(targetFile)-5]+".PNG")
                    print "done"
                '''deleting'''
                delete=True
                #os.remove(targetFile[:len(targetFile)-5]+".PNG")
                #os.remove(targetFile)
            else:
                pass
            if delete:
                print "deleting"
                for targetFile in glob.glob(os.path.join(self.outgoingPath, fileName[:len(fileName)-5]+'.*')):
                    os.remove(targetFile)
                    print"- "+str(targetFile)
                    #os.remove(targetFile[:len(targetFile)-5]+".PNG")
                #os.remove(targetFile)
                print "done"

        self.scheduler.enter(5, 1, self.upload,())

                
    
    def stopAll(self,signal=None,frame=None):
        map(self.scheduler.cancel,self.scheduler.queue)
        self.uploadThread.join()
        print "shutting down uploadserver.py"
        sys.exit()
示例#13
0
time.sleep(10)
ap = AdminPanel(val)
print "######Sleep 10 seconds"
time.sleep(10)
n = Netcraft(val)
print "######Sleep 10 seconds"
time.sleep(10)
sd = SubDomain(val)
print "######Sleep 10 seconds"
time.sleep(10)

gl = GeoLocation(val)
print "######Sleep 10 seconds"
time.sleep(10)

l = Linkedin(val)
print "######Sleep 10 seconds"
time.sleep(10)

f = Facebook(val)
print "######Sleep 10 seconds"
time.sleep(10)

wc = WebCr(val)
print "######Sleep 10 seconds"
time.sleep(10)

m = Metadata(val)
print "######Sleep 10 seconds"
time.sleep(10)
示例#14
0
    'link': 'https://www.exportportal.com/register',
    'datetime': '',
    "server": "eu",
    'title': 'title',
    'image_link':
    'https://pp.userapi.com/c844520/v844520448/bd4e7/wbIdUkZLEJ8.jpg',
    'hashtags': '',
    'page_post': '1',
    "groupe_post": '1',
    "gropes_links": 'link1, link2, link3',
    'priority': "",
}

if json['id'] == "fb":
    FB = Facebook(json['login'], json['pass'], json['text'], json['link'],
                  json['datetime'], json['page_post'], json['groupe_post'],
                  json['title'], json['image_link'], json['hashtags'],
                  json['gropes_links'], json["priority"])
    FB.post()
    print(FB.get_bugrep())
if json['id'] == "tw":
    TW = Twitter(json['login'], json['pass'], json['text'], json['link'],
                 json['datetime'], json['page_post'], json['groupe_post'],
                 json['title'], json['image_link'], json['hashtags'],
                 json['gropes_links'], json['priority'])
    TW.post()
    print(TW.get_bugrep())
if json['id'] == "vk":
    VK = Vkontakte(json['login'], json['pass'], json['text'], json['link'],
                   json['datetime'], json['page_post'], json['groupe_post'],
                   json['title'], json['image_link'], json['hashtags'],
                   json['gropes_links'], json["priority"])