示例#1
0
def search():
    uname = request.args.get('uname')
    storage.addTweets(uname)
    if request.method == 'GET':
        try:
            storage.getInstaInfo(uname)
            pics = instagramhub.user_pics(uname)
            tweets = storage.getTweets(uname)
            photo = tweets[1]
            print storage.getTweets(uname)
            return render_template("instagram.html", tweets = tweets, images = pics, photo = photo)
        except:
            tweets = storage.getTweets(uname)
            print tweets
            queries='?'+'uname='+uname
            api = client.InstagramAPI(client_id='2e1ab1ca522343a589a4dc84eb31af41',
                                      client_secret='67b832ed8a9b4e67b8696a3db0a69fd2',
                                      redirect_uri='http://ml7.stuycs.org:6379/instagram'+ queries)
            return redirect(api.get_authorize_url(scope=['basic']))
示例#2
0
def instagram():
    print 'start'
    #global uname
    #global user_hashtag
    uname = request.args.get('uname')
    user_hashtag = storage.getHash(uname)
    print request.args.keys()
    print uname
    print user_hashtag
    print request.args.get('code')
    try:
        code = request.args.get('code')
    except:
        res = "Missing Code, Please try again"
        return redirect(url_for('instaregister', res = res, uname=uname))
    try:
        print '1'
        code = request.args.get('code')
        print code
        print api
        access_token, instagram_user = api.exchange_code_for_access_token(code)
        print '2'
        print access_token
    except:
        res = "No token, please try again"
        return redirect(url_for('instaregister', res = res, uname = uname))
    user_id = instagram_user['id']
    user_token = access_token
    result = storage.addInstagram(uname, user_token, user_id)
    print user_id + user_hashtag + result
    taggedimages = instagramhub.get_pics(user_id, user_token, user_hashtag)
    photo = taggedimages[0]
    print "Your username" + uname
    print storage.getInfo(uname)
    storage.addTweets(uname)
    tweets = storage.getTweets(uname)
    print tweets
    #print "Here are your tweets" + tweets
    print taggedimages
    return render_template('instagram.html', tweets = tweets, images = taggedimages, user_hashtag = user_hashtag, photo = photo)
示例#3
0
def register():
    if request.method == 'GET':
        return render_template('register.html')
    else:
        btn = request.form['Go']
        if btn == "Submit":
            global success
            global user_hashtag
            global uname
            uerror = ""
            uname = ""
            password = ""
            fullname = ""
            
            user_hashtag = ""
            uname = request.form['username']
            password = request.form['pswd']
            fullname = request.form['name']
            user_hashtag = request.form['hashtag']
            tunames = []
            x = request.form['tuname']
           
            if x != "":
                
                 tunames.append(x)

            x = request.form['tuname2']
           
            if x != "":
                
                 tunames.append(x)

            x = request.form['tuname3']
           
            if x != "":
                 tunames.append(x)
        
            #print "hello" + tunames[0] + tunames[1] + tunames[2]
                
            
            

        
            for x in range(0, len(tunames)):
                if pythontwitter2.tweets.check(tunames[x]) != 1:
                    uerror = "Some of your twitter info isn't valid. Try again."
                    result = 0
                    return render_template('register.html', uerror = uerror)
            if storage.validate(uname, password) == 3:
                if password != "" and fullname != "" and user_hashtag != "" and uname != "" and len(tunames) != 0:
                    result = storage.addUser(uname, password, fullname, tunames, user_hashtag)
                    print storage.addTweets(uname)
                    success = ""
                    print "Your user info:"
                    print storage.getInfo(uname)
                    print storage.getTweets(uname)
                    success = "You succesfully created a new account!"
                    print success
                    #VALUES = {
                     #   'uname': uname,
                      #  'user_hashtag': user_hashtag,
                       #          }
                    return redirect(url_for('instaregister', uname=uname, user_hashtag=user_hashtag))
                #render_template('register.html', terror
            else:
                print "hello" +  tunames[0]
                uerror = "Some of your user info is invalid. Please try again."
                return render_template('register.html', uerror = uerror)