📄 fbapirequest.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3)
// Source File Name: FbAPIRequest.java
package com.sonyericsson.fb.api.request;
import com.sonyericsson.fb.api.FbSessionHandler;
import com.sonyericsson.fb.api.InvalidStateException;
import com.sonyericsson.fb.api.data.FbFriendItemData;
import com.sonyericsson.fb.api.data.FbItemDataFactory;
import com.sonyericsson.fb.io.HttpMultipartRequest;
import com.sonyericsson.fb.utils.Logger;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Vector;
import javax.microedition.io.*;
import se.southend.drops.xml.XMLNode;
import se.southend.drops.xml.XMLParser;
// Referenced classes of package com.sonyericsson.fb.api.request:
// IFbAPIRequest, IFbAPIRequestListener
abstract class FbAPIRequest
implements IFbAPIRequest
{
FbAPIRequest()
{
_statusCode = 1;
_listener = null;
_serverTime = -1L;
}
public void cancelRequest()
{
if(_listener != null)
_listener.requestCancelled(this);
}
public int getRequestStatus()
{
return _statusCode;
}
public long getTimeStamp()
{
return _serverTime;
}
protected int processGetUsers(Vector users, Hashtable userTable)
{
StringBuffer query = new StringBuffer("SELECT uid,name,pic_square,pic,status FROM user WHERE uid IN (");
for(int i = 0; i < users.size(); i++)
{
query.append(users.elementAt(i));
if(i < users.size() - 1)
query.append(",");
else
query.append(")");
}
Hashtable arguments = new Hashtable();
arguments.put("method", "facebook.fql.query");
arguments.put("query", query.toString());
XMLNode root = new XMLNode();
int statusCode = callMethod(arguments, root);
if(statusCode == 0 && root != null && root.getName().equalsIgnoreCase("fql_query_response"))
{
for(int i = 0; i < root.getNumberOfChildren(); i++)
{
XMLNode child = root.getChild(i);
FbFriendItemData user = (FbFriendItemData)FbItemDataFactory.getInstance().createItem(1, child);
if(user != null)
userTable.put(user.getUid(), user);
}
}
return statusCode;
}
protected int callMethod(Hashtable methodSpecificArguments, XMLNode root)
{
String serverUrl;
HttpConnection connection;
byte result[];
serverUrl = "";
try
{
serverUrl = prepareMethodArguments(methodSpecificArguments);
}
catch(InvalidStateException e)
{
return 2003;
}
connection = null;
_serverTime = -1L;
result = null;
char c;
connection = (HttpConnection)Connector.open(serverUrl, 3, true);
HttpMultipartRequest multipart = new HttpMultipartRequest(connection);
if(multipart.preparePostData(methodSpecificArguments))
{
result = multipart.send();
try
{
_serverTime = connection.getHeaderFieldDate("Date", 0L) / 1000L;
}
catch(IOException dateException)
{
Logger.printErrorln("FbAPI.CallMethod(): Failed to get server timestamp! Using system time from phone\r\n");
_serverTime = System.currentTimeMillis() / 1000L;
}
break MISSING_BLOCK_LABEL_167;
}
Logger.printErrorln("FbUploadPhotoRequest.callMethod(): Could not prepare multipart post.");
c = '\u07D0';
Exception e;
if(connection != null)
try
{
connection.close();
}
// Misplaced declaration of an exception variable
catch(Exception e)
{
Logger.printErrorln("FbAPI.CallMethod(): Could not close stream: " + e.toString());
}
return c;
IOException e;
if(connection != null)
try
{
connection.close();
}
// Misplaced declaration of an exception variable
catch(IOException e)
{
Logger.printErrorln("FbAPI.CallMethod(): Could not close stream: " + e.toString());
}
break MISSING_BLOCK_LABEL_335;
e;
Logger.printErrorln("FbAPI.CallMethod(): Error when trying to start a new facebook session: " + e.toString());
if(connection != null)
try
{
connection.close();
}
// Misplaced declaration of an exception variable
catch(IOException e)
{
Logger.printErrorln("FbAPI.CallMethod(): Could not close stream: " + e.toString());
}
break MISSING_BLOCK_LABEL_335;
Exception exception;
exception;
if(connection != null)
try
{
connection.close();
}
catch(IOException e)
{
Logger.printErrorln("FbAPI.CallMethod(): Could not close stream: " + e.toString());
}
throw exception;
ByteArrayInputStream bais;
XMLNode node;
if(result == null)
return 2002;
bais = new ByteArrayInputStream(result);
node = null;
node = XMLParser.getInstance().open(bais);
if(node != null)
break MISSING_BLOCK_LABEL_382;
Logger.printErrorln("FbAPI.CallMethod(): Error when trying to parse XML response from server");
return 2001;
XMLNode error = node.find("error_code");
if(error != null)
{
return Integer.parseInt(error.getValue());
} else
{
root.clone(node);
return 0;
}
error;
Logger.printErrorln("FbAPI.CallMethod(): Error when trying to parse XML response from server: " + error.toString());
return 2001;
}
protected String prepareMethodArguments(Hashtable methodSpecificArguments)
throws InvalidStateException
{
String sessionKey = FbSessionHandler.getInstance().getSessionKey();
String sessionSecret = FbSessionHandler.getInstance().getSessionSecret();
if(sessionSecret.length() == 0)
sessionSecret = "4c2ba82712e7fc831c0ad4f9865922ae";
methodSpecificArguments.put("session_key", sessionKey);
String serverUrl = (String)methodSpecificArguments.get("Url");
if(serverUrl != null)
{
methodSpecificArguments.remove("Url");
} else
{
serverUrl = "http://api.facebook.com/restserver.php";
methodSpecificArguments.put("api_key", "cab9b0c2b22b9628e5d4966412f1c1a1");
methodSpecificArguments.put("v", "1.0");
methodSpecificArguments.put("call_id", (new Long(System.currentTimeMillis())).toString());
}
String signature = FbSessionHandler.getInstance().calculateSignature(methodSpecificArguments, sessionSecret);
methodSpecificArguments.put("sig", signature);
return serverUrl;
}
public abstract void runRequest();
protected int _statusCode;
protected IFbAPIRequestListener _listener;
protected long _serverTime;
private static int _callID = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -