本文整理匯總了Java中com.facebook.internal.ServerProtocol類的典型用法代碼示例。如果您正苦於以下問題:Java ServerProtocol類的具體用法?Java ServerProtocol怎麽用?Java ServerProtocol使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ServerProtocol類屬於com.facebook.internal包,在下文中一共展示了ServerProtocol類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setRequest
import com.facebook.internal.ServerProtocol; //導入依賴的package包/類
protected void setRequest(GraphRequest request) {
this.request = request;
// Make sure that our requests are hitting the latest version of the API known to this
// sdk.
request.setVersion(ServerProtocol.GRAPH_API_VERSION);
request.setCallback(new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
error = response.getError();
if (error != null) {
processError(error);
} else {
processSuccess(response);
}
}
});
}
示例2: build
import com.facebook.internal.ServerProtocol; //導入依賴的package包/類
@Override
public WebDialog build() {
Bundle parameters = getParameters();
parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());
parameters.putString(ServerProtocol.DIALOG_PARAM_E2E, e2e);
parameters.putString(
ServerProtocol.DIALOG_PARAM_RESPONSE_TYPE,
ServerProtocol.DIALOG_RESPONSE_TYPE_TOKEN_AND_SIGNED_REQUEST);
parameters.putString(
ServerProtocol.DIALOG_PARAM_RETURN_SCOPES,
ServerProtocol.DIALOG_RETURN_SCOPES_TRUE);
// Set the re-request auth type for requests
if (isRerequest) {
parameters.putString(
ServerProtocol.DIALOG_PARAM_AUTH_TYPE,
ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE);
}
return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
示例3: tryAuthorize
import com.facebook.internal.ServerProtocol; //導入依賴的package包/類
@Override
boolean tryAuthorize(LoginClient.Request request) {
String e2e = LoginClient.getE2E();
Intent intent = NativeProtocol.createProxyAuthIntent(
loginClient.getActivity(),
request.getApplicationId(),
request.getPermissions(),
e2e,
request.isRerequest(),
request.hasPublishPermission(),
request.getDefaultAudience());
addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);
return tryIntent(intent, LoginClient.getLoginRequestCode());
}
示例4: handleResultCancel
import com.facebook.internal.ServerProtocol; //導入依賴的package包/類
private LoginClient.Result handleResultCancel(LoginClient.Request request, Intent data) {
Bundle extras = data.getExtras();
String error = getError(extras);
String errorCode = extras.getString("error_code");
// If the device has lost network, the result will be a cancel with a connection failure
// error. We want our consumers to be notified of this as an error so they can tell their
// users to "reconnect and try again".
if (ServerProtocol.errorConnectionFailure.equals(errorCode)) {
String errorMessage = getErrorMessage(extras);
return LoginClient.Result.createErrorResult(request, error, errorMessage, errorCode);
}
return LoginClient.Result.createCancelResult(request, error);
}
示例5: build
import com.facebook.internal.ServerProtocol; //導入依賴的package包/類
@Override
public WebDialog build() {
Bundle parameters = getParameters();
parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
parameters.putString(ServerProtocol.DIALOG_PARAM_CLIENT_ID, getApplicationId());
parameters.putString(ServerProtocol.DIALOG_PARAM_E2E, e2e);
parameters.putString(ServerProtocol.DIALOG_PARAM_RESPONSE_TYPE, ServerProtocol.DIALOG_RESPONSE_TYPE_TOKEN);
parameters.putString(ServerProtocol.DIALOG_PARAM_RETURN_SCOPES, ServerProtocol.DIALOG_RETURN_SCOPES_TRUE);
// Only set the rerequest auth type for non legacy requests
if (isRerequest && !Settings.getPlatformCompatibilityEnabled()) {
parameters.putString(ServerProtocol.DIALOG_PARAM_AUTH_TYPE, ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE);
}
return new WebDialog(getContext(), OAUTH_DIALOG, parameters, getTheme(), getListener());
}
示例6: WebDialog
import com.facebook.internal.ServerProtocol; //導入依賴的package包/類
/**
* Constructor which will construct the URL of the Web dialog based on the specified parameters.
*
* @param context the context to use to display the dialog
* @param action the portion of the dialog URL following "dialog/"
* @param parameters parameters which will be included as part of the URL
* @param theme identifier of a theme to pass to the Dialog class
* @param listener the listener to notify, or null if no notification is desired
*/
public WebDialog(Context context, String action, Bundle parameters, int theme, OnCompleteListener listener) {
super(context, theme);
if (parameters == null) {
parameters = new Bundle();
}
// our webview client only handles the redirect uri we specify, so just hard code it here
parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
parameters.putString(ServerProtocol.DIALOG_PARAM_DISPLAY, DISPLAY_TOUCH);
Uri uri = Utility.buildUri(
ServerProtocol.getDialogAuthority(),
ServerProtocol.getAPIVersion() + "/" + ServerProtocol.DIALOG_PATH + action,
parameters);
this.url = uri.toString();
onCompleteListener = listener;
}
示例7: handleResultOk
import com.facebook.internal.ServerProtocol; //導入依賴的package包/類
private AuthorizationClient.Result handleResultOk(Intent paramIntent)
{
Bundle localBundle = paramIntent.getExtras();
String str1 = localBundle.getString("error");
String str2 = str1;
if (str1 == null)
str2 = localBundle.getString("error_type");
String str3 = localBundle.getString("error_code");
String str4 = localBundle.getString("error_message");
String str5 = str4;
if (str4 == null)
str5 = localBundle.getString("error_description");
String str6 = localBundle.getString("e2e");
if (!Utility.isNullOrEmpty(str6))
AuthorizationClient.this.logWebLoginCompleted(this.applicationId, str6);
if ((str2 == null) && (str3 == null) && (str5 == null))
{
AccessToken localAccessToken = AccessToken.createFromWebBundle(AuthorizationClient.this.pendingRequest.getPermissions(), localBundle, AccessTokenSource.FACEBOOK_APPLICATION_WEB);
return AuthorizationClient.Result.createTokenResult(AuthorizationClient.this.pendingRequest, localAccessToken);
}
if (ServerProtocol.errorsProxyAuthDisabled.contains(str2))
return null;
if (ServerProtocol.errorsUserCanceled.contains(str2))
return AuthorizationClient.Result.createCancelResult(AuthorizationClient.this.pendingRequest, null);
return AuthorizationClient.Result.createErrorResult(AuthorizationClient.this.pendingRequest, str2, str5, str3);
}
示例8: handleResultOk
import com.facebook.internal.ServerProtocol; //導入依賴的package包/類
private Result handleResultOk(Intent data) {
Bundle extras = data.getExtras();
String error = extras.getString("error");
if (error == null) {
error = extras.getString("error_type");
}
if (error == null) {
AccessToken token = AccessToken.createFromWebBundle(pendingRequest.getPermissions(), extras,
AccessTokenSource.FACEBOOK_APPLICATION_WEB);
return Result.createTokenResult(token);
} else if (ServerProtocol.errorsProxyAuthDisabled.contains(error)) {
return null;
} else if (ServerProtocol.errorsUserCanceled.contains(error)) {
return Result.createCancelResult(null);
} else {
return Result.createErrorResult(error, extras.getString("error_description"));
}
}
示例9: testSingleGetToHttpRequest
import com.facebook.internal.ServerProtocol; //導入依賴的package包/類
@SmallTest
@MediumTest
@LargeTest
public void testSingleGetToHttpRequest() throws Exception {
Request requestMe = new Request(null, "TourEiffel");
HttpURLConnection connection = Request.toHttpConnection(requestMe);
assertTrue(connection != null);
assertEquals("GET", connection.getRequestMethod());
assertEquals("/" + ServerProtocol.getAPIVersion() + "/TourEiffel", connection.getURL().getPath());
assertTrue(connection.getRequestProperty("User-Agent").startsWith("FBAndroidSDK"));
Uri uri = Uri.parse(connection.getURL().toString());
assertEquals("android", uri.getQueryParameter("sdk"));
assertEquals("json", uri.getQueryParameter("format"));
}
示例10: handleResultOk
import com.facebook.internal.ServerProtocol; //導入依賴的package包/類
private LoginClient.Result handleResultOk(LoginClient.Request request, Intent data) {
Bundle extras = data.getExtras();
String error = getError(extras);
String errorCode = extras.getString("error_code");
String errorMessage = getErrorMessage(extras);
String e2e = extras.getString(NativeProtocol.FACEBOOK_PROXY_AUTH_E2E_KEY);
if (!Utility.isNullOrEmpty(e2e)) {
logWebLoginCompleted(e2e);
}
if (error == null && errorCode == null && errorMessage == null) {
try {
AccessToken token = createAccessTokenFromWebBundle(request.getPermissions(),
extras, AccessTokenSource.FACEBOOK_APPLICATION_WEB,
request.getApplicationId());
return LoginClient.Result.createTokenResult(request, token);
} catch (FacebookException ex) {
return LoginClient.Result.createErrorResult(request, null, ex.getMessage());
}
} else if (ServerProtocol.errorsProxyAuthDisabled.contains(error)) {
return null;
} else if (ServerProtocol.errorsUserCanceled.contains(error)) {
return LoginClient.Result.createCancelResult(request, null);
} else {
return LoginClient.Result.createErrorResult(request, error, errorMessage, errorCode);
}
}
示例11: tryAuthorize
import com.facebook.internal.ServerProtocol; //導入依賴的package包/類
@Override
boolean tryAuthorize(AuthorizationRequest request) {
applicationId = request.getApplicationId();
String e2e = getE2E();
Intent intent = NativeProtocol.createProxyAuthIntent(context, request.getApplicationId(),
request.getPermissions(), e2e, request.isRerequest());
addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);
return tryIntent(intent, request.getRequestCode());
}