本文整理汇总了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());
}