com.facebook.HttpMethod Java Examples
The following examples show how to use
com.facebook.HttpMethod.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 6 votes |
/** * 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); }
Example #2
Source File: ShareApi.java From kognitivo with Apache License 2.0 | 6 votes |
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(); }
Example #3
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 5 votes |
/** * 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 image 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 */ public static GraphRequest newUploadStagingResourceWithImageRequest( AccessToken accessToken, Bitmap image, Callback callback) { Bundle parameters = new Bundle(1); parameters.putParcelable(STAGING_PARAM, image); return new GraphRequest( accessToken, MY_STAGING_RESOURCES, parameters, HttpMethod.POST, callback); }
Example #4
Source File: FlowApiRequests.java From flow-android with MIT License | 5 votes |
public static void getUserCoverImage(final Context context, final String fbid, final ImageView imageView, final FlowImageLoaderCallback callback){ Bundle params = new Bundle(); params.putString("fields", "cover"); new Request( Session.getActiveSession(), "/" + fbid, params, HttpMethod.GET, new Request.Callback() { public void onCompleted(Response response) { GraphObject graphObject = response.getGraphObject(); if (graphObject != null && graphObject.getProperty("cover") != null) { if (graphObject != null && graphObject.getProperty("cover") != null) { try { JSONObject json = graphObject.getInnerJSONObject(); String url = json.getJSONObject("cover").getString("source"); FlowImageLoader loader = new FlowImageLoader(context); loader.loadImage(url, imageView, callback); } catch (Exception e) { Crashlytics.logException(e); } } } } } ).executeAsync(); }
Example #5
Source File: FacebookShareActivity.java From FacebookImageShareIntent with MIT License | 5 votes |
private void postImageToFacebook() { Session session = Session.getActiveSession(); final Uri uri = (Uri) mExtras.get(Intent.EXTRA_STREAM); final String extraText = mPostTextView.getText().toString(); if (session.isPermissionGranted("publish_actions")) { Bundle param = new Bundle(); // Add the image try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte[] byteArrayData = stream.toByteArray(); param.putByteArray("picture", byteArrayData); } catch (IOException ioe) { // The image that was send through is now not there? Assert.assertTrue(false); } // Add the caption param.putString("message", extraText); Request request = new Request(session,"me/photos", param, HttpMethod.POST, new Request.Callback() { @Override public void onCompleted(Response response) { addNotification(getString(R.string.photo_post), response.getGraphObject(), response.getError()); } }, null); RequestAsyncTask asyncTask = new RequestAsyncTask(request); asyncTask.execute(); finish(); } }
Example #6
Source File: FiscalizacaoConcluidaActivity.java From vocefiscal-android with Apache License 2.0 | 5 votes |
private void publishStory(Session session) { Bundle postParams = new Bundle(); postParams.putString("name", "Você Fiscal"); // Receber os dados da eleição!!! postParams.putString("message", "Eu fiscalizei a seção: "+ this.secao +"\nNa zona eleitoral: " + this.zonaEleitoral + "\nNo município de: " + this.municipio); postParams.putString("description", "Obrigado por contribuir com a democracia!"); postParams.putString("link", "http://www.vocefiscal.org/"); postParams.putString("picture", "http://imagizer.imageshack.us/v2/150x100q90/913/bAwPgx.png"); Request.Callback callback= new Request.Callback() { public void onCompleted(Response response) { JSONObject graphResponse = response.getGraphObject().getInnerJSONObject(); String postId = "Compartilhado com sucesso!"; try { postId = graphResponse.getString("Compartilhado com sucesso!"); } catch (JSONException e) { } FacebookRequestError error = response.getError(); if (error != null) { Toast.makeText(FiscalizacaoConcluidaActivity.this.getApplicationContext(),error.getErrorMessage(),Toast.LENGTH_SHORT).show(); } else { Toast.makeText(FiscalizacaoConcluidaActivity.this.getApplicationContext(), postId, Toast.LENGTH_LONG).show(); } } }; Request request = new Request(session, "me/feed", postParams, HttpMethod.POST, callback); RequestAsyncTask task = new RequestAsyncTask(request); task.execute(); }
Example #7
Source File: UserRequest.java From edx-app-android with Apache License 2.0 | 5 votes |
public static void makeUserRequest(GraphRequest.Callback callback) { final Bundle params = new Bundle(); params.putString("fields", "name,id,email"); final GraphRequest request = new GraphRequest( AccessToken.getCurrentAccessToken(), ME_ENDPOINT, params, HttpMethod.GET, callback ); request.executeAsync(); }
Example #8
Source File: FacebookHelper.java From argus-android with Apache License 2.0 | 5 votes |
public void logout() { if (AccessToken.getCurrentAccessToken() == null) { return; // already logged out } new GraphRequest(AccessToken.getCurrentAccessToken(), "/me/permissions/", null, HttpMethod.DELETE, new GraphRequest .Callback() { @Override public void onCompleted(GraphResponse graphResponse) { LoginManager.getInstance().logOut(); } }).executeAsync(); }
Example #9
Source File: Utility.java From kognitivo with Apache License 2.0 | 5 votes |
private static GraphRequest getGraphMeRequestWithCache( final String accessToken) { Bundle parameters = new Bundle(); parameters.putString("fields", "id,name,first_name,middle_name,last_name,link"); parameters.putString("access_token", accessToken); GraphRequest graphRequest = new GraphRequest( null, "me", parameters, HttpMethod.GET, null); return graphRequest; }
Example #10
Source File: FBLoginInstance.java From ShareLoginPayUtil with Apache License 2.0 | 5 votes |
@SuppressLint("CheckResult") @Override public void fetchUserInfo(final BaseToken token) { Bundle params = new Bundle(); params.putString("fields", "picture,name,id,email,permissions"); request = new GraphRequest(((FacebookToken) token).getAccessTokenBean(), "/me", params, HttpMethod.GET, new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse response) { try { if (response != null && response.getJSONObject() != null) { ShareLogger.i(response.getJSONObject().toString()); FacebookUser faceBookUser = new FacebookUser(response.getJSONObject()); mLoginListener.loginSuccess(new LoginResultData(LoginPlatform.FACEBOOK, token, faceBookUser)); } else { mLoginListener.loginFailure(new JSONException("解析GraphResponse异常!!"), 303); } LoginUtil.recycle(); } catch (JSONException e) { e.printStackTrace(); } } }); request.executeAsync(); }
Example #11
Source File: VideoUploader.java From kognitivo with Apache License 2.0 | 5 votes |
protected void executeGraphRequestSynchronously(Bundle parameters) { GraphRequest request = new GraphRequest( uploadContext.accessToken, String.format(Locale.ROOT, "%s/videos", uploadContext.graphNode), parameters, HttpMethod.POST, null); GraphResponse response = request.executeAndWait(); if (response != null) { FacebookRequestError error = response.getError(); JSONObject responseJSON = response.getJSONObject(); if (error != null) { if (!attemptRetry(error.getSubErrorCode())) { handleError(new FacebookGraphResponseException(response, ERROR_UPLOAD)); } } else if (responseJSON != null) { try { handleSuccess(responseJSON); } catch (JSONException e) { endUploadWithFailure(new FacebookException(ERROR_BAD_SERVER_RESPONSE, e)); } } else { handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE)); } } else { handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE)); } }
Example #12
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 5 votes |
/** * 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 imageUri the file:// or content:// Uri pointing to 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, Uri imageUri, Callback callback ) throws FileNotFoundException { if (Utility.isFileUri(imageUri)) { return newUploadStagingResourceWithImageRequest( accessToken, new File(imageUri.getPath()), callback); } else if (!Utility.isContentUri(imageUri)) { throw new FacebookException("The image Uri must be either a file:// or content:// Uri"); } GraphRequest.ParcelableResourceWithMimeType<Uri> resourceWithMimeType = new GraphRequest.ParcelableResourceWithMimeType<>(imageUri, "image/png"); Bundle parameters = new Bundle(1); parameters.putParcelable(STAGING_PARAM, resourceWithMimeType); return new GraphRequest( accessToken, MY_STAGING_RESOURCES, parameters, HttpMethod.POST, callback); }
Example #13
Source File: KlyphQuery.java From KlyphMessenger with MIT License | 4 votes |
@Override public HttpMethod getHttpMethod() { return HttpMethod.GET; }
Example #14
Source File: PostUnsureEventRequest.java From Klyph with MIT License | 4 votes |
public HttpMethod getHttpMethod() { return HttpMethod.POST; }
Example #15
Source File: NewAlbumRequest.java From Klyph with MIT License | 4 votes |
public HttpMethod getHttpMethod() { return HttpMethod.POST; }
Example #16
Source File: EditCommentRequest.java From Klyph with MIT License | 4 votes |
@Override public HttpMethod getHttpMethod() { return HttpMethod.POST; }
Example #17
Source File: PostDeclineEventRequest.java From Klyph with MIT License | 4 votes |
public HttpMethod getHttpMethod() { return HttpMethod.POST; }
Example #18
Source File: PostCommentRequest.java From Klyph with MIT License | 4 votes |
public HttpMethod getHttpMethod() { return HttpMethod.POST; }
Example #19
Source File: DeleteStatusRequest.java From Klyph with MIT License | 4 votes |
public HttpMethod getHttpMethod() { return HttpMethod.DELETE; }
Example #20
Source File: PostPokeRequest.java From Klyph with MIT License | 4 votes |
@Override public HttpMethod getHttpMethod() { return HttpMethod.POST; }
Example #21
Source File: KlyphQuery.java From Klyph with MIT License | 4 votes |
@Override public HttpMethod getHttpMethod() { return HttpMethod.GET; }
Example #22
Source File: DeleteObjectRequest.java From Klyph with MIT License | 4 votes |
public HttpMethod getHttpMethod() { return HttpMethod.DELETE; }
Example #23
Source File: PostUnlikeRequest.java From Klyph with MIT License | 4 votes |
@Override public HttpMethod getHttpMethod() { return HttpMethod.DELETE; }
Example #24
Source File: PostLikeRequest.java From Klyph with MIT License | 4 votes |
@Override public HttpMethod getHttpMethod() { return HttpMethod.POST; }
Example #25
Source File: PostReadNotificationRequest.java From Klyph with MIT License | 4 votes |
@Override public HttpMethod getHttpMethod() { return HttpMethod.POST; }
Example #26
Source File: PostStatusRequest.java From Klyph with MIT License | 4 votes |
public HttpMethod getHttpMethod() { return HttpMethod.POST; }
Example #27
Source File: PostAttendEventRequest.java From Klyph with MIT License | 4 votes |
public HttpMethod getHttpMethod() { return HttpMethod.POST; }
Example #28
Source File: ShareApi.java From kognitivo with Apache License 2.0 | 4 votes |
private void shareOpenGraphContent(final ShareOpenGraphContent openGraphContent, final FacebookCallback<Sharer.Result> callback) { // In order to create a new Open Graph action using a custom object that does not already // exist (objectID or URL), you must first send a request to post the object and then // another to post the action. If a local image is supplied with the object or action, that // must be staged first and then referenced by the staging URL that is returned by that // request. 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 ShareOpenGraphAction action = openGraphContent.getAction(); final Bundle parameters = action.getBundle(); this.addCommonParameters(parameters, openGraphContent); if (!Utility.isNullOrEmpty(this.getMessage())) { parameters.putString("message", this.getMessage()); } final CollectionMapper.OnMapperCompleteListener stageCallback = new CollectionMapper .OnMapperCompleteListener() { @Override public void onComplete() { try { handleImagesOnAction(parameters); new GraphRequest( AccessToken.getCurrentAccessToken(), getGraphPath( URLEncoder.encode(action.getActionType(), DEFAULT_CHARSET)), parameters, HttpMethod.POST, requestCallback).executeAsync(); } catch (final UnsupportedEncodingException ex) { ShareInternalUtility.invokeCallbackWithException(callback, ex); } } @Override public void onError(FacebookException exception) { ShareInternalUtility.invokeCallbackWithException(callback, exception); } }; this.stageOpenGraphAction(parameters, stageCallback); }
Example #29
Source File: RequestQuery.java From Klyph with MIT License | votes |
public HttpMethod getHttpMethod();
Example #30
Source File: RequestQuery.java From KlyphMessenger with MIT License | votes |
public HttpMethod getHttpMethod();