我已经编写了一个程序来集成在C#中的Facebook用户聊天,但是我总是<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>在将响应发送到服务器之后得到.
我检查了API密钥和App秘密,两者都是正确的.看起来我将一些错误的参数传递给服务器.
这是我的代码.
private void GetDetailsButton_Click(object sender, EventArgs e)
{
TcpClient FacebookClient = new TcpClient();
FacebookClient.Connect("chat.facebook.com", 5222);
NetworkStream myns = FacebookClient.GetStream();
string xml = "<?xml version='1.0'?>" +
"<stream:stream " +
"id='1' " +
"to='chat.facebook.com' " +
"xmlns='jabber:client' " +
"xmlns:stream='http://etherx.jabber.org/streams' " +
"version='1.0' >";
StreamWriter mySw = new StreamWriter(myns);
mySw.WriteLine(xml); //sending initial request
mySw.Flush();
byte[] serverResponseByte = new byte[1024];
int myBytesRead = 0;
StringBuilder myResponseAsSB = new StringBuilder();
//reading response from the server to see the supported …Run Code Online (Sandbox Code Playgroud) 请先在这里发帖,请保持温柔.我正在使用Smack库构建一个Facebook聊天客户端.我正在使用X-FACEBOOK-PLATFORM方法,以免保存任何密码.我使用oauth 1.0正常工作,并希望将其更改为2.0,导致10月1日截止日期; p.根据我的理解,为了迁移到2.0,我必须做的唯一事情是删除"sig"和"session_key"参数并添加"access_token"参数,但我得到的是"SASL身份验证X-FACEBOOK- PLATFORM失败:未经授权:".我正在使用这个自定义SASLMechanism类:
package smackresearching;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import javax.security.sasl.Sasl;
import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.sasl.SASLMechanism;
import org.jivesoftware.smack.util.Base64;
public class SASLXFacebookPlatformMechanism extends SASLMechanism {
public static final String NAME = "X-FACEBOOK-PLATFORM";
private String apiKey = "";
private String accessToken = "";
/**
* Constructor.
*/
public SASLXFacebookPlatformMechanism(SASLAuthentication saslAuthentication) {
super(saslAuthentication);
}
@Override
protected void authenticate() throws IOException, XMPPException {
// Send the authentication to the server
getSASLAuthentication().send(new AuthMechanism(getName(), ""));
}
@Override
public …Run Code Online (Sandbox Code Playgroud) 我在html文件中有以下代码:
<html>
<head>
<title>My Great Website</title>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId:'156154681125939', cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'apprequests',
message: 'Here is a new Requests dialog...'});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我正在使用此代码发送我的应用程序的apprequests(参考:http://developers.facebook.com/blog/post/464/)
问题:我能够通过上面的代码加载请求对话,并显示我的朋友列表.我也可以发送邀请.假设我将邀请发送给朋友"X"(提供"X"尚未使用我的应用程序).然后在X的FB帐户中,apprequest书签计数增加1.但是当X试图查看应用程序邀请时,他实际上看不到我的应用程序收到的任何应用程序邀请.我已经尝试过至少5个用户,在我向他们发送邀请后,他们的apprequest书籍增加了1,但是当他们看到邀请时,实际上没有邀请.
任何人都可以建议我这是什么问题?
注意:我的应用程序是网站(而不是画布应用程序),我也在我的服务器上托管了上面的演示代码,网址为http://www.gmarjil.com/a.html
facebook facebook-graph-api facebook-social-plugins x-facebook-platform