我有这个代码:
if 'instagramTV' in path:
self.send_response(200)
instaShortcode, LTV, EMAIL, TIME, userID, URL = map(\
qs.get, ['instaID', 'channelID', 'uEmail', 'Time', 'uID', 'contentUrl'])
channelID, uEmail, instagramShortcode, uTime, uID, contentUrl = map(\
lambda x : str(x)[2:-2], [LTV, EMAIL, instaShortcode, TIME, userID, URL])
for i in (channelID, uEmail, instagramShortcode, uTime, uID, contentUrl):
print i
instaSTEP2 = requests.get("http://api.instagram.com/oembed?url=http://instagr.am/p/%s/"% instagramShortcode).json()
instaMeID = instaSTEP2['media_id']
instaINFO = requests.get("https://api.instagram.com/v1/media/%s?accesstoken=295391286.1b882b8.33fa51373fae4885b5c60ceb186e6560" % instaMeID).json()
print instaINFO['data']['user']['profile_picture']
print instaINFO['data']['user']['username']
print instaINFO['data']['caption']['text']
print instaINFO['data']['images']['standard_resolution']['url']
ltvMSG = {'fromEMAIL': 'uEmail', 'toCHANNELID': 'channelID', 'timeSENT': 'uTime', 'profiePIC': "instaINFO['data']['user']['profile_picture']",'userNAME': "instaINFO['data']['user']['username']", 'msgBODY': "instaINFO['data']['caption']['text']", 'msgIMAGE': "instaINFO['data']['images']['standard_resolution']['url']"}
print ltvMSG
首先 vars 来自 http get 请求,然后我使用其中一些 vars 进行 api 调用,然后我返回一些 json。
我正在尝试将 get 请求中的一些初始变量和 api 调用中的一些值放入我自己的 dict/json 中,最终将进入 redis 列表。
print ltvMSG 返回:
{'userNAME': "instaINFO['data']['user']['username']", 'timeSENT': 'uTime', 'msgIMAGE': "instaINFO['data']['images']['standard_resolution']['url']", 'msgBODY': "instaINFO['data']['caption']['text']", 'fromEMAIL': 'uEmail', 'toCHANNELID': 'channelID', 'profilePIC': "instaINFO['data']['user']['profile_picture']"}
这是我想要的结构,但是如何使实际值显示为键的值。