鉴于公开Facebook帖子的URL,如何在FB Graph API中找到帖子对象?(其次,当通过API访问时,为什么这么多用户提要为空或几乎为空?)
我们希望能够在评论或喜欢通过V2.X图形API后,鉴于这篇文章的网址.这样做需要post的对象ID,我们可以做一些有根据的猜测,但是通过API访问实际对象已被证明是不可靠的(适用于某些帖子但不适用于其他帖子).
API的v2引入了应用范围的用户ID,帖子ID通常似乎是{app-scoped user id} _ {unique post id}的形式.以下是使用这些ID的各种组合(全局用户ID,应用程序范围的用户ID和帖子ID)在API中查找帖子的一些尝试的详细信息.
从一个简单的例子开始:https://www.facebook.com/evan.prodromou/posts/10153023417510505.关键特征是它是公开的,它不是另一个帖子的共享,最重要的是它没有照片,它为单个照片和照片集添加额外的ID和URL.Evan的个人资料也是公开的,即https://www.facebook.com/evan.prodromou不显示通用这个内容目前无法提供
从该URL尝试裸帖子ID,/ v1.0/10153023417510505和/v2.2/10153023417510505都会给出不支持的get请求(代码100)错误.
Evan的全局用户ID是525575504.将其作为前缀附加,/ v1.0/525575504_10153023417510505和/v2.2/525575504_10153023417510505仍然都提供相同的不支持的get请求错误.
使用他的应用程序范围的用户ID代替相同的错误,/ v2.2/10152350676805505_10153023417510505.
好吧让我们试试另一个方向.我们将浏览用户的Feed,直到找到相关帖子.感觉这更像是API 的预期用例......
无论是全球/v2.2/525575504/posts和应用范围的/v2.2/10152350676805505/posts返回任何结果,但/v1.0/525575504/posts返回最近的文章中,这好像和这个职位.不知道为什么只有那两个,尽管最近有很多其他的公开帖子.可以id在两个api版本中通过其字段获取类似内容,即/v1.0/525575504_10153045879215505和/v2.2/10152350676805505_10153045879215505,但是两个API版本在通过其id字段(例如/ v1)获取帖子时返回Unsupported get request错误. 0/525575504_351575675029953和/v2.2/10152350676805505_351575675029953
尝试另一个公开发布的帖子,这个帖子有图片:https://www.facebook.com/andigalpern/posts/678121182314631./v1.0/100003502653187_678121182314631, …
facebook facebook-graph-api facebook-graph-api-v2.2 indieweb
使用SWIG为C++应用程序生成Python接口,有没有办法让它在生成的.py文件中注释函数?我实际上将整个.h文件放入.i文件中,但是一个小例子:
%module example
bool do_something_interesting(int number, string text);
Run Code Online (Sandbox Code Playgroud)
swig -python example.i 产生:
...
def do_something_interesting(*args):
return _example.do_something_interesting(*args)
do_something_interesting = _example.do_something_interesting
Run Code Online (Sandbox Code Playgroud)
理想情况下,我希望它能够使用原始方法签名自动添加注释
#bool do_something_interesting(int number, string text)
def do_something_interesting(*args):
return _example.do_something_interesting(*args)
do_something_interesting = _example.do_something_interesting
Run Code Online (Sandbox Code Playgroud)
但我完全可以在某处写自己的评论(特别是如果评论可能以某种方式在.h文件中).我认为%pythonprepend可能是一个可能的解决方案,但它在函数定义中而不是在它之前插入代码.
编辑:这是我在.h文件中提出的.不是最漂亮的东西,但它会做:
#ifdef SWIG
%pythonprepend do_something_interesting(int, string) %{
"""Do some interesting thing
number:Int -- a number
text:String -- some text
"""
%}
#endif
bool do_something_interesting(int number, string text);
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个类似的功能std::for_each,除了正常使用外,还可以使用std::function<bool (param)>.错误的返回值意味着我想要摆脱循环.下面的代码是我到目前为止所获得的代码.
a.visit([&](int) -> void)在评估时,第二次调用不会编译!visitor(i).是否有可能使这项工作或我咆哮错误的树?
我正在使用MSVC 2010,但希望代码通常与C++ 11兼容.
#include <list>
#include <string>
#include <iostream>
struct A
{
std::list<int> _lst;
template<typename _F>
void visit(_F visitor)
{
for(std::list<int>::const_iterator it = _lst.begin(), end = _lst.end() ; it != end ; it++) {
int i = *it;
if (std::is_void<decltype(visitor(i))>::value) {
visitor(i);
} else {
if (!visitor(i)) { // <----- error C2171: '!' : illegal on operands of type 'void'
break;
}
}
}
}
};
int main(int argc, char* …Run Code Online (Sandbox Code Playgroud) 我正在Clojure的一个小游戏中进行学习练习.我想我已经在任何特定时间确定了游戏状态的表示,作为"可移动物"列表和"地形"(板块正方形)的2D矢量矢量.
95%的时间我希望检查2D矢量看起来合适的特定方块中的碰撞.但在少数情况下,我需要转向另一个方向 - 找到符合某些条件的单元格的(x,y)位置.第一次尝试是这样的:
(defn find-cell-row [fn row x y]
(if (empty? row) nil
(if (fn (first row)) [x y]
(find-cell-row fn (rest row) (inc x) y))))
(defn find-cell [fn grid y]
(if (empty? grid) nil
(or (find-cell-row fn (first grid) 0 y)
(find-cell (rest grid) (inc y)))))
(def sample [[\a \b \c][\d \e \f]])
(find-cell #(= % \c) sample 0) ;; => [2 0]
Run Code Online (Sandbox Code Playgroud)
我用map-indexed尝试了一些更简洁的东西,但是很快就变得丑陋而且仍然没有给我我想要的东西.是否有更惯用的方式来进行此搜索,或者我可能会更好地使用不同的数据结构?也许是地图{[xy] - > cell}?使用地图来表示矩阵对我来说感觉很不对:)