FileDocCategorySizeDatePackage
FacebookJaxbRestClient.javaAPI DocGoogle Facebook API v1.413695Fri Nov 02 14:57:34 GMT 2007com.facebook.api

FacebookJaxbRestClient

public class FacebookJaxbRestClient extends ExtensibleClient
A FacebookRestClient that JAXB response objects. This means results from calls to the Facebook API are returned as XML and transformed into JAXB Java objects.

Fields Summary
Constructors Summary
public FacebookJaxbRestClient(String apiKey, String secret)
Constructor.

param
apiKey your Facebook API key
param
secret your 'secret' Facebook key

      this(SERVER_URL, apiKey, secret, null);
    
public FacebookJaxbRestClient(String apiKey, String secret, String sessionKey)
Constructor.

param
apiKey your Facebook API key
param
secret your 'secret' Facebook key
param
sessionKey the session-id to use

      this(SERVER_URL, apiKey, secret, sessionKey);
    
public FacebookJaxbRestClient(String serverAddr, String apiKey, String secret, String sessionKey)
Constructor.

param
serverAddr the URL of the Facebook API server to use
param
apiKey your Facebook API key
param
secret your 'secret' Facebook key
param
sessionKey the session-id to use
throws
MalformedURLException if you specify an invalid URL

      this(new URL(serverAddr), apiKey, secret, sessionKey);
    
public FacebookJaxbRestClient(URL serverUrl, String apiKey, String secret, String sessionKey)
Constructor.

param
serverUrl the URL of the Facebook API server to use
param
apiKey your Facebook API key
param
secret your 'secret' Facebook key
param
sessionKey the session-id to use

      super(serverUrl, apiKey, secret, sessionKey);
    
Methods Summary
public java.lang.Stringauth_getSession(java.lang.String authToken)
Call this function to retrieve the session information after your user has logged in.

param
authToken the token returned by auth_createToken or passed back to your callback_url.

      if (null != this._sessionKey) {
        return this._sessionKey;
      }
      SessionInfo d =
        (SessionInfo) this.callMethod(FacebookMethod.AUTH_GET_SESSION, 
                        new Pair<String, CharSequence>("auth_token", authToken.toString()));
      this._sessionKey = d.getSessionKey();
      this._userId = d.getUid();
      if (this._isDesktop) {
        this._sessionSecret =
            d.getSecret();
      }
      return this._sessionKey;
    
public java.lang.Stringdata_getUserPreference(java.lang.Integer prefId)

          throw new FacebookException(ErrorCode.GEN_UNKNOWN_METHOD, "The FacebookJsonRestClient does not support this API call.  Please use an instance of FacebookRestClient instead.");
      
public java.util.Mapdata_getUserPreferences()

          throw new FacebookException(ErrorCode.GEN_UNKNOWN_METHOD, "The FacebookJsonRestClient does not support this API call.  Please use an instance of FacebookRestClient instead.");
      
public voiddata_setUserPreference(java.lang.Integer prefId, java.lang.String value)

          throw new FacebookException(ErrorCode.GEN_UNKNOWN_METHOD, "The FacebookJsonRestClient does not support this API call.  Please use an instance of FacebookRestClient instead.");
          
      
public voiddata_setUserPreferences(java.util.Map values, boolean replace)

          throw new FacebookException(ErrorCode.GEN_UNKNOWN_METHOD, "The FacebookJsonRestClient does not support this API call.  " +
                  "Please use an instance of FacebookRestClient instead.");
          
      
protected booleanextractBoolean(java.lang.Object val)
Extracts a Boolean from a result that consists of a Boolean only.

param
val
return
the Boolean

        String result = parse();
        if (("1".equals(result)) || ("true".equalsIgnoreCase(result))) {
            return true;
        }
        return false;
    
protected intextractInt(java.lang.Object val)
Extracts an Integer from a result that consists of an Integer only.

param
val
return
the Integer

      try {
        return Integer.parseInt(parse());
      } catch (Exception cce) {
        logException(cce);
        return 0;
      }
    
protected java.lang.LongextractLong(java.lang.Object val)
Extracts a Long from a result that consists of an Long only.

param
val
return
the Integer

        try {
            return Long.parseLong(parse());
          } catch (Exception cce) {
            logException(cce);
            return null;
          }
    
public java.lang.StringextractString(java.lang.Object val)
Extracts a String from a result consisting entirely of a String.

param
val
return
the String

      return parse();
    
protected java.net.URLextractURL(java.lang.Object url)
Extracts a URL from a result that consists of a URL only. For JSON, that result is simply a String.

param
url
return
the URL

      String result = parse();
      if (result != null) {
          return new URL(result);
      }
      return null;
    
public voidfbml_setRefHandle(java.lang.String handle, java.lang.String markup)

          throw new FacebookException(ErrorCode.GEN_UNKNOWN_METHOD, "The FacebookJsonRestClient does not support this API call.  " +
          "Please use an instance of FacebookRestClient instead.");
          
      
public java.lang.StringgetResponseFormat()
The response format in which results to FacebookMethod calls are returned

return
the format: either XML, JSON, or null (API default)

      return "xml";
    
public java.util.Listmarketplace_getListings(java.util.List listingIds, java.util.List uids)

          MarketplaceGetListingsResponse resp = (MarketplaceGetListingsResponse)this.marketplace_getListings(listingIds, uids);
          return resp.getListing();
      
public java.util.Listmarketplace_getSubCategories()

          MarketplaceGetSubCategoriesResponse resp = (MarketplaceGetSubCategoriesResponse)this.marketplace_getSubCategories(null);
          return resp.getMarketplaceSubcategory();
      
public java.util.Listmarketplace_search(com.facebook.api.MarketListingCategory category, com.facebook.api.MarketListingSubcategory subcategory, java.lang.String searchTerm)

          MarketplaceSearchResponse resp = (MarketplaceSearchResponse)this.marketplace_search(category.getName(), subcategory.getName(), searchTerm);
          return resp.getListing();
      
private java.lang.Stringparse()

        String xml = this.rawResponse;
        if ((xml == null) || ("".equals(xml))) {
            return null;
        }
        if (! xml.contains("</")) {
            return null;
        }
        xml = xml.substring(0, xml.indexOf("</"));
        xml = xml.substring(xml.lastIndexOf(">" + 1));
        return xml;
    
protected java.lang.ObjectparseCallResult(java.io.InputStream data, com.facebook.api.IFacebookMethod method)
Parses the result of an API call from XML into JAXB Objects.

param
data an InputStream with the results of a request to the Facebook servers
param
method the method
return
a JAXB Object
throws
FacebookException if data represents an error
throws
IOException if data is not readable

      if (isDebug()) {
          System.out.println("Facebook response:  " + this.rawResponse);
      }
      Object res = this.getResponsePOJO();
      if (res instanceof FacebookApiException) {
          FacebookApiException error = (FacebookApiException)res;
          int errorCode = error.getErrorCode();
          String message = error.getErrorMsg();
          throw new FacebookException(errorCode, message);
          
      }
        return this.getResponsePOJO();
    
public booleansms_canSend()

          throw new FacebookException(ErrorCode.GEN_UNKNOWN_METHOD, "The FacebookJsonRestClient does not support this API call.  " +
          "Please use an instance of FacebookRestClient instead.");
      
public booleansms_canSend(java.lang.Long userId)

          throw new FacebookException(ErrorCode.GEN_UNKNOWN_METHOD, "The FacebookJsonRestClient does not support this API call.  " +
          "Please use an instance of FacebookRestClient instead.");
      
public java.lang.Integersms_send(java.lang.String message, java.lang.Integer smsSessionId, boolean makeNewSession)

          throw new FacebookException(ErrorCode.GEN_UNKNOWN_METHOD, "The FacebookJsonRestClient does not support this API call.  " +
          "Please use an instance of FacebookRestClient instead.");
      
public java.lang.Integersms_send(java.lang.Long userId, java.lang.String message, java.lang.Integer smsSessionId, boolean makeNewSession)

          throw new FacebookException(ErrorCode.GEN_UNKNOWN_METHOD, "The FacebookJsonRestClient does not support this API call.  " +
          "Please use an instance of FacebookRestClient instead.");