我一直在研究通过fConnect连接到Facebook的iPhone应用程序(与客户端-服务器通信)。 iphone应用程序正在处理facebook身份验证和其他通信,它们都工作正常。
现在,由于一些优化问题,我们希望从服务器端而不是客户端处理应用程序的fb墙贴功能。为了完成我们正在做的任务,是将所有数据(也包括fb访问 token )发送到服务器端,并通过图形api将http发布请求发送到facebook。在响应中,它向我们发送了一个错误:
{"error":{"message":"Invalid token: \"610446057\". An ID has already been specified.","type":"OAuthException","code":2500}}
HttpClient client = new HttpClient();
client.getParams().setParameter("http.useragent", "Test Client");
PostMethod method = new PostMethod("https://graph.facebook.com/610446057?access_token=MY_VALID_TOKEN_HERE");
method.addParameter("id", "610446057");
method.addParameter("name", "Zunair Minhas");
method.addParameter("picture", "http://profile.ak.fbcdn.net/hprofile-ak-ash2/276791_19292868552_1958181823_s.jpg");
method.addParameter("link", "http://www.google.com.pk");
method.addParameter("company_overview", "FB Wall post without fb integration. It is a simple Http Post request.");
client.executeMethod(method);
def reader = method.getResponseBodyAsString();
String data = reader.readLines().join()
method.releaseConnection();
最佳答案
您所要做的就是删除以下行:
method.addParameter("id", "610446057");
https://graph.facebook.com/610446057
传递它https://graph.facebook.com/me/feed?access_token=<xxx>
https://stackoverflow.com/questions/9601451/