本文整理汇总了Python中models.Post.new_from_json_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Post.new_from_json_dict方法的具体用法?Python Post.new_from_json_dict怎么用?Python Post.new_from_json_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Post
的用法示例。
在下文中一共展示了Post.new_from_json_dict方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: related
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import new_from_json_dict [as 别名]
def related(self, days=14, limit=10, page=10, section="", _callback=None):
options = {'uuid': self.uuid, 'days': days, 'limit': limit, 'page': page}
handler = self._build_callback(
lambda res: [Post.new_from_json_dict(x) for x in res['data']],
_callback)
res = self.conn._request_endpoint('/related', options,
_callback=handler if _callback else None)
return handler(res) if not _callback else None
示例2: search
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import new_from_json_dict [as 别名]
def search(self, query, limit=10, page=1, _callback=None):
handler = self._build_callback(
lambda res: [Post.new_from_json_dict(x) for x in res['data']],
_callback)
res = self.conn._request_endpoint('/search', {'q': query, 'limit': limit,
'page': page},
_callback=handler if _callback else None)
return handler(res) if not _callback else None
示例3: post_detail
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import new_from_json_dict [as 别名]
def post_detail(self, post, days='', _callback=None):
url = post.url if hasattr(post, 'url') else post
handler = self._build_callback(
lambda res: Post.new_from_json_dict(res['data'][0]),
_callback)
res = self.conn._request_endpoint('/analytics/post/detail',
{'url': url, 'days': days},
_callback=handler if _callback else None)
return handler(res) if not _callback else None
示例4: meta_detail
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import new_from_json_dict [as 别名]
def meta_detail(self, meta_obj, aspect="author", _callback=None, **kwargs):
value = getattr(meta_obj, aspect) if hasattr(meta_obj, aspect) else meta_obj
options = self._format_analytics_args(**kwargs)
handler = self._build_callback(
lambda res: [Post.new_from_json_dict(x) for x in res['data']],
_callback)
res = self.conn._request_endpoint('/analytics/%s/%s/detail' % (aspect, value),
options, _callback=handler if _callback else None)
return handler(res) if not _callback else None
示例5: referrers_meta_detail
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import new_from_json_dict [as 别名]
def referrers_meta_detail(self, meta_obj, ref_type="social", meta="author",
domain='', days=3, _callback=None, **kwargs):
value = getattr(meta_obj, meta) if hasattr(meta_obj, meta) else meta_obj
dates = self._format_date_args(**kwargs)
options = {'domain': domain, 'days': days}
handler = self._build_callback(
lambda res: [Post.new_from_json_dict(x) for x in res['data']],
_callback)
res = self.conn._request_endpoint('/referrers/%s/%s/%s/detail' % (ref_type, meta, value),
dict(options.items() + dates.items()),
_callback=handler if _callback else None)
return handler(res) if not _callback else None