Commit 61af6094 by 柴鹏飞

dmp接口调整

parent ed769b35
...@@ -69,7 +69,7 @@ class UserCFRecommender(Recommender): ...@@ -69,7 +69,7 @@ class UserCFRecommender(Recommender):
self.k = k self.k = k
self.logger = create_logger(__name__, 'recommender.log') self.logger = create_logger(__name__, 'recommender.log')
config = configparser.RawConfigParser() config = configparser.RawConfigParser()
config.read(get_conf_path()) config.read(get_conf_path())
self.dmp_url = config.get('DMP', 'url') self.dmp_url = config.get('DMP', 'url')
...@@ -112,9 +112,9 @@ class UserCFRecommender(Recommender): ...@@ -112,9 +112,9 @@ class UserCFRecommender(Recommender):
def get_user_profile(self, user_id): def get_user_profile(self, user_id):
if user_id == '0': if user_id == '0':
return [] return []
headers = { headers = {
'X-App-Id': 'plough_cloud', 'X-App-Id': 'plough_cloud',
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
...@@ -127,7 +127,7 @@ class UserCFRecommender(Recommender): ...@@ -127,7 +127,7 @@ class UserCFRecommender(Recommender):
} }
try: try:
response = requests.request('POST', self.dmp_url, headers=headers, json=payload) response = requests.request('POST', self.dmp_url + user_id, headers=headers, json=payload)
resp = response.json() resp = response.json()
return resp['data']['objects'][0] return resp['data']['objects'][0]
except Exception as e: except Exception as e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment