从c / c ++或linux发布在facebook墙上

时间:2011-12-26 12:16:01

标签: c++ c facebook-graph-api curl

任何人都可以指出一种从C程序在我的Facebook墙上发布的方法(不使用任何非标准库;卷曲是可以的!)。

如果没有/可用,你是否至少可以从bash shell中提出一个解决方案(所以我可以将它与c system()一起使用)。我在互联网上找到了一些,但没有一个使用新的Facebook图形API。

1 个答案:

答案 0 :(得分:3)

一旦您向应用程序授予publish_stream权限,您就可以执行以下操作,从 C

创建用户Feed(墙)中的帖子
curl = curl_easy_init();

char *data="message=Posting from C&";
strcat(data, "link=http://placekitten.com&");
strcat(data, "picture=http://placekitten.com/90/90&");
strcat(data, "name=Meow&");
strcat(data, "caption={*actor*} places kittens on the wall&");
strcat(data, "description=Some description&");
strcat(data, "access_token=USER_OR_APPLICATION_ACCESS_TOKEN");

curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_setopt(curl, CURLOPT_URL, "https://graph.facebook.com/me/feed");
/* Disable SSL check (only for testing) */
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);

curl_easy_perform(curl); /* post */

图谱API非常简单,您应该阅读documentation了解更多信息,在您的情况下,您可能需要阅读有关posting in feed的其他详细信息

相关问题