コード例 #1
0
ファイル: yahoo.py プロジェクト: blorenz/seocortex
    def add(self, jsondata = None, profile_id= None):
        if not jsondata:
            return json.dumps({"status" : "failed", "error" : "nodata"})

        # deserialize
        d = json.loads(jsondata)

        try:
            account = YahooAccountEmbedded()
            account.firstname = d['firstname']
            account.lastname = d['lastname']
            account.yahooid = d['yahooid']
            account.password = d['password']
            account.secret1 = d['secret1']
            account.secret2 = d['secret2']
            account.postalcode = d['postalcode']
            account.birthday = datetime.date(d['birthyear'], d['birthmonth'], d['birthday'])

            # Add account to a profile that doesn't have one yet
            try:
                if profile_id:
                    jkprofile = JokerProfile.objects.get(id = profile_id)
                else:
                    jkprofile = JokerProfile.objects.filter(accounts__yahoo__exists = False)[0]
            except:
                jkprofile = JokerProfile()
            jkprofile.add_account(account)
            jkprofile.save()

        except Exception as e:
            return json.dumps({"status" : "failed", "error" : unicode(e)})

        return json.dumps({"status" : "success"}) 
コード例 #2
0
ファイル: twitter.py プロジェクト: blorenz/seocortex
    def add(self, jsondata = None, profile_id = None):

        if not jsondata:
            return json.dumps({"status" : "failed", "error" : "nodata"})

        # deserialize
        d = json.loads(jsondata)

        try:
            account = TwitterAccountEmbedded()
            account.name = d['name']
            account.username = d['username']
            account.password = d['password']

            # Add account to a profile that doesn't have one yet
            try:
                if profile_id:
                    jkprofile = JokerProfile.objects.get(id = profile_id)
                else:
                    jkprofile = JokerProfile.objects.filter(accounts__twitter__exists = False)[0]
            except:
                jkprofile = JokerProfile()
            jkprofile.add_account(account)
            jkprofile.save()

        except Exception as e:
            return json.dumps({"status" : "failed", "error" : unicode(e)})

        return json.dumps({"status" : "success"}) 
コード例 #3
0
twitter.username = "******"
twitter.password = "******"

# Build Yahoo account
yahoo = YahooAccountEmbedded()
yahoo.yahooid = "SomeYahooId"
yahoo.password = "******"
yahoo.firstname = "john"
yahoo.lastname = "smith"
yahoo.secret1 = "secret1"
yahoo.secret2 = "secret2"
yahoo.postalcode = "90210"
yahoo.birthday = datetime.datetime.now()

# Build JokerProfile
joker = JokerProfile()

# Add accounts
joker.add_account(twitter)
joker.add_account(yahoo)

# Save and exit
joker.save()

val = joker.to_mongo()
val2 = joker._data
print("[%s] :\n%s\n\n" % (type(val), val))
print("[%s] :\n%s\n\n" % (type(val2), val2))


print("In JSON : \n%s" % json.dumps(val))