How to publish UIImage to Facebook - facebook

I want to publish image from UIImage to Facebook however this code needs imageURL. How?
(void) publishFeedWithName:(NSString*)name
captionText:(NSString*)caption
imageurl:(NSString*)url
linkurl:(NSString*)href
userMessagePrompt:(NSString*)prompt
actionLabel:(NSString*)label
actionText:(NSString*)text
actionLink:(NSString*)link
targetId:(NSString*)target{
[self postFeedWithName:name
captionText:caption
imageurl:url
linkurl:href
userMessagePrompt:prompt
actionLabel:label
actionText:text
actionLink:link
targetId:target];
}

First you need to get the image as a JPG or other transmittable file image. That can be done with UIImageJPEGRepresentation as described about halfway down here: https://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more
I don't have access right now to the box where I have the Facebook SDK installed and the example app that can upload an image, so I can't tell you the details of how to do that at present. But the Facebook SDK example package shows you how to do it.

Related

Embedded Instagram Post doesn't show the image

I use the Embed-Button from Instagram and use the generated Embed-Code:
when I embed an Insta-Post on my website without image caption, it doesn't load the image.
But when I check the the inclusion for image caption it works fine: codepen.io/cheshirecat/pen/eYjrYZr
What I'am doing wrong?

how to: save image data to gallery [Flutter]

I have 1 question:
I use a library and it returns the Image data type, so how do I save or share the image in the library of my device?
code:
Image image = await HmsScanUtils.buildBitmap(request);
https://pub.dev/packages/gallery_saver
This plugin saves images and videos to gallery/photos.
You need to provide a path to the file that you want to save like below:
GallerySaver.saveImage(path)
You can use this package
https://pub.dev/packages/gallery_saver.
If you dont understand any documentation given on this page then you can simply follow the following tutorial by Johannes
https://www.youtube.com/watch?v=JILcQLZvjKE

Take screenshot of host app using iOS share/action extensions?

I will like to know how to take a screenshot of the iOS host app with the use of a share/action extension.
My use case is as follows:
use the Safari browser to access a webpage (https such as gmail)
tap on the Share button and select the extension
the extension will take a screenshot of the current webpage
An working example for this use case is the Awesome Screenshot iOS app.
I had tried the following methods
reload the baseURI (loadRequest) on a UIWebView/WKWebkit (would not be able to access https contents such as Gmail). So not doing any reload (Awesome Screenshot is not doing a reload btw)
Used the ExtensionPreprocessingJS to obtain the DOM contents through the arguments.completionFunction function. I could not extract the document.body here although i could get the source etc. loadHTMLString with the baseURI will mess up the presentation layer.
Used html2canvas in the ExtensionPreprocessingJS to obtain an image and appended it to the host app's webpage as a child but do not know how to extract it. Also, the image got lost for some webpages such as Gmail.
Mobile Safari does not have the visibleContentsAsDataURL method.
I think a viable approach will be to use the html2canvas in the ExtensionPreprocessingJS but how do I save this image somehow?
Edit: So the below works in the Simulator but does not work on the device. I'm presently looking for a solution as well.
Here's a solution that I think the Awesome Screenshot app uses:
func captureScreen() -> UIImage
{
// Get the "screenshot" view.
let view = UIScreen.mainScreen().snapshotViewAfterScreenUpdates(false)
// Add the screenshot view as a subview of the ShareViewController's view.
self.view.addSubview(view);
// Now screenshot *this* view.
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, false, 0);
self.view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Finally, remove the subview.
view.removeFromSuperview()
return image
}

How are text images processed by Facebook?

This code is processed as goku image on FB chat:
[[236823566443944]][[236823583110609]][[236823586443942]][[236823596443941]][[236823609777273]]
[[236823629777271]][[236823636443937]][[236823649777269]][[236823663110601]][[236823673110600]]
[[236823683110599]][[236823686443932]][[236823696443931]][[236823699777264]][[236823709777263]]
[[236823716443929]][[236823733110594]][[236823736443927]][[236823749777259]][[236823753110592]]
[[236823756443925]][[236823759777258]][[236823769777257]][[236823779777256]][[236823783110589]]
[[236823789777255]][[236823793110588]][[236823796443921]][[236823806443920]][[236823809777253]]
How FB creates image from this? I found the code on symbols-n-emoticons in comments below, copied&pasted into FB chat and - black magic - the image was there.
So I took your example and did some testing. If yout right click on the image in chat and look at it URL, you can find following:
https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-ash4/227547_236823636443937_1841629131_n.jpg
It's one tile from the goku image. The middle part of the URL corresponds to one value in you code. So this code are actually shortcuts to images stored on FB servers, and the chat window simply replaces the code with image.
I think it could be due to latest update in FB, which allows you to attach images directly to posts.
[EDIT]
I have tried several other images and it worked for all images hosted akamaihd.net aka Facebook hosting. Just grab the secod number and past it in chat in double brackets.
The image is always resized to 16x16px, hence the code for Goku is so long, it's actually made from tiles.

iPhone action button image file available anywhere?

I'm working on an app and want to use the image from the action type toolbar button (the one with the arrow coming from the box that we often use for share etc) in a custom button. Is there some way I can get hold of the .png for it?
Thanks
There is the open source UIKit artwork extractor project available at Github: https://github.com/0xced/UIKit-Artwork-Extractor
There's a mockup toolkit available for iOS SDK at http://blog.metaspark.com/2009/02/fireworks-toolkit-for-creating-iphone-ui-mockups/
Check the fourth image on right most column. I hope it contains the image you want.
You can download the mockup toolkit and open up with fireworks or photoshop to extract images from there. If you don't have these adobe softwares then the open source software GIMP is your good friend to extract the image.
There really is no need to duplicate the image content since its already in the framework.
Have a look at this code:
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:#selector(onActionButtonClicked:)];
The relevant portion being the initWithBarButtonSystemItem initialization method.
This question may also be more useful in answering this question than the selected answer.