本文整理匯總了Java中com.facebook.HttpMethod類的典型用法代碼示例。如果您正苦於以下問題:Java HttpMethod類的具體用法?Java HttpMethod怎麽用?Java HttpMethod使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HttpMethod類屬於com.facebook包,在下文中一共展示了HttpMethod類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: newUploadStagingResourceWithImageRequest
import com.facebook.HttpMethod; //導入依賴的package包/類
/**
* Creates a new Request configured to upload an image to create a staging resource. Staging
* resources allow you to post binary data such as images, in preparation for a post of an Open
* Graph object or action which references the image. The URI returned when uploading a staging
* resource may be passed as the image property for an Open Graph object or action.
*
* @param accessToken the access token to use, or null
* @param file the file containing the image to upload
* @param callback a callback that will be called when the request is completed to handle
* success or error conditions
* @return a Request that is ready to execute
* @throws FileNotFoundException
*/
public static GraphRequest newUploadStagingResourceWithImageRequest(
AccessToken accessToken,
File file,
Callback callback
) throws FileNotFoundException {
ParcelFileDescriptor descriptor =
ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
GraphRequest.ParcelableResourceWithMimeType<ParcelFileDescriptor> resourceWithMimeType =
new GraphRequest.ParcelableResourceWithMimeType<>(descriptor, "image/png");
Bundle parameters = new Bundle(1);
parameters.putParcelable(STAGING_PARAM, resourceWithMimeType);
return new GraphRequest(
accessToken,
MY_STAGING_RESOURCES,
parameters,
HttpMethod.POST,
callback);
}
示例2: shareLinkContent
import com.facebook.HttpMethod; //導入依賴的package包/類
private void shareLinkContent(final ShareLinkContent linkContent,
final FacebookCallback<Sharer.Result> callback) {
final GraphRequest.Callback requestCallback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
final JSONObject data = response.getJSONObject();
final String postId = (data == null ? null : data.optString("id"));
ShareInternalUtility.invokeCallbackWithResults(callback, postId, response);
}
};
final Bundle parameters = new Bundle();
this.addCommonParameters(parameters, linkContent);
parameters.putString("message", this.getMessage());
parameters.putString("link", Utility.getUriString(linkContent.getContentUrl()));
parameters.putString("picture", Utility.getUriString(linkContent.getImageUrl()));
parameters.putString("name", linkContent.getContentTitle());
parameters.putString("description", linkContent.getContentDescription());
parameters.putString("ref", linkContent.getRef());
new GraphRequest(
AccessToken.getCurrentAccessToken(),
getGraphPath("feed"),
parameters,
HttpMethod.POST,
requestCallback).executeAsync();
}
示例3: getPermissions
import com.facebook.HttpMethod; //導入依賴的package包/類
public void getPermissions() {
String uri = "me/permissions/";
new GraphRequest(AccessToken.getCurrentAccessToken(),
uri, null, HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
JSONArray data = response.getJSONObject().optJSONArray("data");
mUserPermissions.clear();
for (int i = 0; i < data.length(); i++) {
JSONObject dd = data.optJSONObject(i);
if (dd.optString("status").equals("granted")) {
mUserPermissions
.add(dd.optString("permission"));
}
}
}
}
).executeAsync();
}
示例4: doFacebookCall
import com.facebook.HttpMethod; //導入依賴的package包/類
protected void doFacebookCall(Activity parent, Map<String, Object> postData, String graphPath, HttpMethod method, SocialNetworkPostListener listener) {
Bundle bundle = new Bundle();
if(postData != null) {
Set<Entry<String, Object>> entries = postData.entrySet();
for (Entry<String, Object> entry : entries) {
Object value = entry.getValue();
if(value instanceof byte[]) {
bundle.putByteArray(entry.getKey(), (byte[]) value);
}
else {
bundle.putString(entry.getKey(), value.toString());
}
}
}
doFacebookCall(parent, bundle, graphPath, method, listener);
}
示例5: createAppLinkIfNeeded
import com.facebook.HttpMethod; //導入依賴的package包/類
private void createAppLinkIfNeeded() {
if (mPlace != null && mAppLink == null && Utils.isConnected(getContext())) {
String token = getContext().getString(R.string.facebook_app_id) + "|" +
getContext().getString(R.string.facebook_app_secret);
Bundle parameters = new Bundle();
parameters.putString("name", "Sjekk Ut");
parameters.putString("access_token", token);
parameters.putString("web", "{\"should_fallback\": false}");
parameters.putString("iphone", "[{\"url\": \"sjekkut://place/" + mPlace.getId() + "\"}]");
parameters.putString("android", "[{\"url\": \"no.dnt.sjekkut://place/" + mPlace.getId() + "\", \"package\": \"no.dnt.sjekkut\"}]");
new GraphRequest(
null,
"/app/app_link_hosts",
parameters,
HttpMethod.POST,
this).executeAsync();
}
}
示例6: getThirdPartyFriendIds
import com.facebook.HttpMethod; //導入依賴的package包/類
@Override
public List<String> getThirdPartyFriendIds() throws SocialNetworkException {
if (!isAuthorizedToSocialNetwork()) {
throw new NotAuthorizedToSocialNetworkException();
}
GraphResponse response = new GraphRequest(
facebookTokenHolder.getToken(),
FACEBOOK_FRIENDS_GRAPH_PATH,
Bundle.EMPTY,
HttpMethod.GET
).executeAndWait();
facebookTokenHolder.clearToken();
FacebookRequestError responseError = response.getError();
if (responseError != null) {
throw new SocialNetworkException("Internal facebook failure: "
+ responseError.getErrorMessage() + " [" + responseError.getErrorCode() + "]");
}
return extractFacebookFriendIds(response);
}
示例7: setPhoto
import com.facebook.HttpMethod; //導入依賴的package包/類
public void setPhoto(final ImageView imageView, final Button button){
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"me?fields=picture.width(500).height(500)",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
try {
Log.d("LOG onComplete", String.valueOf(AccessToken.getCurrentAccessToken()));
String url=new FacebookJsonParse().FacebookImageParse(response.getJSONObject());
imageView.setVisibility(View.VISIBLE);
button.setVisibility(View.GONE);
Glide.with(context).load(url).into(imageView);
} catch (JSONException e) {
Log.d("FacebookSdkHelper",e.getMessage());
}
}
}
).executeAsync();
}
示例8: execute
import com.facebook.HttpMethod; //導入依賴的package包/類
protected void execute() {
if (sessionManager.isLoggedIn()) {
AccessToken accessToken = sessionManager.getAccessToken();
Bundle bundle = updateAppSecretProof();
GraphRequest request = new GraphRequest(accessToken, getGraphPath(),
bundle, HttpMethod.GET);
request.setVersion(configuration.getGraphVersion());
runRequest(request);
} else {
String reason = Errors.getError(Errors.ErrorMsg.LOGIN);
Logger.logError(getClass(), reason, null);
if (mSingleEmitter != null) {
mSingleEmitter.onError(new FacebookAuthorizationException(reason));
}
}
}
示例9: getFacebookInfo
import com.facebook.HttpMethod; //導入依賴的package包/類
private void getFacebookInfo() {
Bundle parameters = new Bundle();
parameters.putString("fields", "picture, first_name, id");
new GraphRequest(AccessToken.getCurrentAccessToken(), "/me", parameters, HttpMethod.GET, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
JSONObject user = graphResponse.getJSONObject();
ParseUser currentUser = ParseUser.getCurrentUser();
currentUser.put("firstName", user.optString("first_name"));
currentUser.put("facebookId", user.optString("id"));
currentUser.put("pictureURL", user.optJSONObject("picture").optJSONObject("data").optString("url"));
currentUser.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if(e == null) {
Log.i(TAG, "User saved");
setResult(RESULT_OK);
finish();
}
}
});
}
}).executeAsync();
}
示例10: newPostOpenGraphObjectRequest
import com.facebook.HttpMethod; //導入依賴的package包/類
/**
* Creates a new Request configured to create a user owned Open Graph object.
*
* @param accessToken the accessToken to use, or null
* @param openGraphObject the Open Graph object to create; must not be null, and must have a
* non-empty type and title
* @param callback a callback that will be called when the request is completed to handle
* success or error conditions
* @return a Request that is ready to execute
*/
public static GraphRequest newPostOpenGraphObjectRequest(
AccessToken accessToken,
JSONObject openGraphObject,
Callback callback) {
if (openGraphObject == null) {
throw new FacebookException("openGraphObject cannot be null");
}
if (Utility.isNullOrEmpty(openGraphObject.optString("type"))) {
throw new FacebookException("openGraphObject must have non-null 'type' property");
}
if (Utility.isNullOrEmpty(openGraphObject.optString("title"))) {
throw new FacebookException("openGraphObject must have non-null 'title' property");
}
String path = String.format(MY_OBJECTS_FORMAT, openGraphObject.optString("type"));
Bundle bundle = new Bundle();
bundle.putString(OBJECT_PARAM, openGraphObject.toString());
return new GraphRequest(accessToken, path, bundle, HttpMethod.POST, callback);
}
示例11: newUpdateOpenGraphObjectRequest
import com.facebook.HttpMethod; //導入依賴的package包/類
/**
* Creates a new Request configured to update a user owned Open Graph object.
*
* @param accessToken the access token to use, or null
* @param openGraphObject the Open Graph object to update, which must have a valid 'id'
* property
* @param callback a callback that will be called when the request is completed to handle
* success or error conditions
* @return a Request that is ready to execute
*/
public static GraphRequest newUpdateOpenGraphObjectRequest(
AccessToken accessToken,
JSONObject openGraphObject,
Callback callback) {
if (openGraphObject == null) {
throw new FacebookException("openGraphObject cannot be null");
}
String path = openGraphObject.optString("id");
if (path == null) {
throw new FacebookException("openGraphObject must have an id");
}
Bundle bundle = new Bundle();
bundle.putString(OBJECT_PARAM, openGraphObject.toString());
return new GraphRequest(accessToken, path, bundle, HttpMethod.POST, callback);
}
示例12: newUploadPhotoRequest
import com.facebook.HttpMethod; //導入依賴的package包/類
/**
* Creates a new Request configured to upload a photo to the user's default photo album. The
* photo will be read from the specified Uri.
* @param accessToken the access token to use, or null
* @param photoUri the file:// or content:// Uri to the photo on device.
* @param callback a callback that will be called when the request is completed to handle
* success or error conditions
* @return a Request that is ready to execute
* @throws FileNotFoundException
*/
public static GraphRequest newUploadPhotoRequest(
AccessToken accessToken,
Uri photoUri,
Callback callback)
throws FileNotFoundException {
if (Utility.isFileUri(photoUri)) {
return newUploadPhotoRequest(accessToken, new File(photoUri.getPath()), callback);
} else if (!Utility.isContentUri(photoUri)) {
throw new FacebookException("The photo Uri must be either a file:// or content:// Uri");
}
Bundle parameters = new Bundle(1);
parameters.putParcelable(PICTURE_PARAM, photoUri);
return new GraphRequest(accessToken, MY_PHOTOS, parameters, HttpMethod.POST, callback);
}
示例13: newUploadVideoRequest
import com.facebook.HttpMethod; //導入依賴的package包/類
/**
* Creates a new Request configured to upload a photo to the user's default photo album. The
* photo will be read from the specified Uri.
* @param accessToken the access token to use, or null
* @param videoUri the file:// or content:// Uri to the video on device.
* @param callback a callback that will be called when the request is completed to handle
* success or error conditions
* @return a Request that is ready to execute
* @throws FileNotFoundException
*/
public static GraphRequest newUploadVideoRequest(
AccessToken accessToken,
Uri videoUri,
Callback callback)
throws FileNotFoundException {
if (Utility.isFileUri(videoUri)) {
return newUploadVideoRequest(accessToken, new File(videoUri.getPath()), callback);
} else if (!Utility.isContentUri(videoUri)) {
throw new FacebookException("The video Uri must be either a file:// or content:// Uri");
}
Bundle parameters = new Bundle(1);
parameters.putParcelable(PICTURE_PARAM, videoUri);
return new GraphRequest(accessToken, MY_PHOTOS, parameters, HttpMethod.POST, callback);
}
示例14: newStatusUpdateRequest
import com.facebook.HttpMethod; //導入依賴的package包/類
/**
* Creates a new Request configured to post a status update to a user's feed.
*
* @param accessToken the access token to use, or null
* @param message the text of the status update
* @param placeId an optional place id to associate with the post
* @param tagIds an optional list of user ids to tag in the post
* @param callback a callback that will be called when the request is completed to handle
* success or error conditions
* @return a Request that is ready to execute
*/
private static GraphRequest newStatusUpdateRequest(
AccessToken accessToken,
String message,
String placeId,
List<String> tagIds,
Callback callback) {
Bundle parameters = new Bundle();
parameters.putString("message", message);
if (placeId != null) {
parameters.putString("place", placeId);
}
if (tagIds != null && tagIds.size() > 0) {
String tags = TextUtils.join(",", tagIds);
parameters.putString("tags", tags);
}
return new GraphRequest(accessToken, MY_FEED, parameters, HttpMethod.POST, callback);
}
示例15: shareLinkContent
import com.facebook.HttpMethod; //導入依賴的package包/類
private void shareLinkContent(final ShareLinkContent linkContent,
final FacebookCallback<Sharer.Result> callback) {
final GraphRequest.Callback requestCallback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
final JSONObject data = response.getJSONObject();
final String postId = (data == null ? null : data.optString("id"));
ShareInternalUtility.invokeCallbackWithResults(callback, postId, response);
}
};
final Bundle parameters = new Bundle();
parameters.putString("link", Utility.getUriString(linkContent.getContentUrl()));
parameters.putString("picture", Utility.getUriString(linkContent.getImageUrl()));
parameters.putString("name", linkContent.getContentTitle());
parameters.putString("description", linkContent.getContentDescription());
parameters.putString("ref", linkContent.getRef());
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/feed",
parameters,
HttpMethod.POST,
requestCallback).executeAsync();
}