URL Error posting image to facebook - android

I want to send a image taken by the user to a Facebook share dialog post.
The image taken from device camera h is set to a imageview and also saved to the device external storage/ SD card.
The facebook share SDK takes a URL for a image in the .setPicture(URL) method.
So my question is it possible to get the URL of a image from either the bitmap in the imageview or the image stored in the deice?
Or is the URL specifically for a network resource?
Cheers
ciaran
EDIT: Have tried adding the path to sd card/external storage of device as a string to the
setLink(URL string) method:
setLink("/storage/emulated/0/dive_photos/image2462.png")
but image does not load, exceptions thrown in Logcat is ....
03-02 00:06:04.280: E/Activity(3055): Error:
com.facebook.FacebookException: Error publishing message Share preview
could not be fetched
(#100)picture url not properly formed
Treied removing the first "/" by getting substring(1) and passing setLink("storage/emulated/0/dive_photos/image2462.png")
but same error....
Although a network resource url works fine:
setLink("http://www.mooneycallans.com/images/Gallery/image51.jpg")
EDIT:
Also tried creating a file://imagePathString URL some progress made, the share preview will show the image however will still not post get the same (#100) Pictire URL not properly formed....
File imagePathFile = new File(savedImagePath);
try{
userImageURL = imagePathFile.toURI().toURL();
Log.d(TAG, "File URL for saved image on FB: " + userImageURL);
}catch(MalformedURLException ex){
//ex.printStackTrace();
}
userImageURLString = userImageURL.toString();
setPicture(userImageURLString)
//userImageURLString = "file:/storage/emulated/0/dive_photos/image4373.png";
My head is wrecked:(

After much seraching a very confusing FB documentation I found the method
setPicture(URL string)
will only accept a network resource URL.
To upload a photo form app need the Request class:
Request.newUploadPhotoRequest(session, imagePathFile, uploadPhotoRequestCallback);

Related

How to get the image content url from Dropbox without expiration?

I am trying to get the image URL from the Dropbox and I followed the below code from the documentation.
try {
Entry directory = dropboxApi.metadata("/", 1000, null, true, null);
directory.mimeType = "image*//*";
for (Entry entry : directory.contents) {
DropboxAPI.DropboxLink link = dropboxApi.media(entry.path, false);
if (link.url.contains(".jpeg") || link.url.contains(".png") || link.url.contains(".jpg"))
files.add(link.url);
}
} catch (DropboxException e) {
e.printStackTrace();
}
Based on this code I can get the image URL. But it is not working after hours.
In my scenario, I want to get the image URL and I will send it to server API. So when I retrieve other API, I will get the image URL, what I sent. Once I got the URL, just I want to set it to imageview.
I have verified this link. I got the different link by using share method. But I don't know how to set that into my ImageView, whereas by using media method I can get the URL and I can set it to ImageView.
Please can someone help me to solve this problem
If i make an Http request for share url then I am getting image name with download option.
I am getting 16 headers.
From this am not getting any clue. There is no header name contains Location.There is one content-piracy-policy which gives some url values combined. But it is also not relevant.

Retrieve Android/Cloudinary uploaded image URL

Im using Cloudinary along with an Android App.
Im uploading a image using:
cloudinary.uploader().upload(imagePath, ObjectUtils.emptyMap());
The problem is that I need the url to retrieve this image later. Is there any method that I can use to store the uploaded image url inside my App?
Thanks!
According to their documentation
Documentaion
This code shows
Map uploadResult = cloudinary.uploader().upload(file, ObjectUtils.emptyMap());
Uploading is performed synchronously. Once finished, the uploaded image is immediately available for manipulation and delivery.
An upload API call returns a JSON object with content similar to that shown in the following example:
{
"public_id":"tquyfignx5bxcbsupr6a",
"version":1375302801,
"signature":"52ecf23eeb987b3b5a72fa4ade51b1c7a1426a97",
"width":1920,
"height":1200,
"format":"jpg",
"resource_type":"image",
"created_at":"2013-07-31T20:33:21Z",
"bytes":737633,
"type":"upload",
"url":
"http://res.cloudinary.com/demo/image/upload/v1375302801/tquyfignx5bxcbsupr6a.jpg",
"secure_url":
"https://res.cloudinary.com/demo/image/upload/v1375302801/tquyfignx5bxcbsupr6a.jpg",
"etag":"1adf8d2ad3954f6270d69860cb126b24"
}
The response is automatically parsed and converted into a Map.

Unable to fetch GPlus profile pic. Is the Google Plus Image fetch URL updated?

It's weird, but till yesterday i was able to get the gplus user's image in my app but today it's just not coming. Nothing simply blank. And just appears at some time..
I have been using the urls specified in Getting Google+ profile picture url with user_id but these all seem invalid and gives 404 Error.
https://plus.google.com/s2/photos/profile/116018066779980863044?sz=100
If anybody could help me out why this weird behaviour. The Profile pic appears seldom. But mostly it's blank.
The image URL you were using was never a public API and so there was no guarantee it would continue to work. The recommended practice going forward is to use the people.get API method to get the profile => image => url value instead. That URL could stop working if the user changes their avatar so you might want to fetch the actual image and cache it on your own servers.
I think the Image url has been updated.
Inorder to get that, we can use the PlusClient objects methods:
imageURL = mPlusClient.getCurrentPerson().getImage().getUrl()
{Returns a String - Image Url as String}
imageURL = mPlusClient.getCurrentPerson().getImage()
{Returns an instance of Image object}

Download image from new Google+ (plus) Photos Of Gallery with Image Extension

In new android version, they have added gplus photo section in gallery.
In my application, i have incorporated the logic of selecting image from it and display to the user using below link of stackoverflow:
Download image from new Google+ (plus) Photos Application
However, i also need image extension as we are sending image raw data with extension of selected picture to the API. gplus returns the image path like this
content://com.google.android.apps.photos.content/0/https%3A%2F%2Flh5.googleusercontent.com%<a bunch of letters and numbers here>
So, how can i get extension of that image also from gplus?? Any idea??
I AM SUCCESSFULLY GETTING BITMAP FROM ABOVE URI. I JUST NEED EXTENSION OF THAT IMAGE NOW.
Thanks.
Use ContentResolver.getType(uri):
Uri uri = // your content://com.google.android.apps.photos.content URI
String mimeType = getContentResolver().getType(uri);
// mimeType will be image/png, image/jpeg, etc.

How To Get Clear Image From FaceBook

I used graph API Json Response of Facebook Wall Post Images and display in my APP i successfully got it. But the wall images look very Blur how to resolve? i used this code for get wall picture
URL url=new URL(hashMap.get("picture_url"));
bitmap=BitmapFactory.decodeStream(url.openConnection().getInputStream());
((ImageView)view.findViewById(R.id.imageView_FullImage)).setImageBitmap(bitmap)
The Facebook Graph API as well as the FQL data set always returns the Picture URL of a thumbnail. If you look at the URL it returns, it will have one of these ending (right before the image extension .jpg, .png, etc) _t., _a.. For example, if the URL is to a JPG file, it could have an ending _t.jpg
The idea is to swap the ending and choose a normal size for the image that is returned. To do this, use the code below that will replace the endings with the one for normal sized images (that should have the _n.)
By the way, I don't think the tag you are looking for is picture_url. It should be just picture. But regardless, get the source URL as shown below, replace the endings and then pass it to the this line in your code:
// THIS SHOULD BE AFTER THE if....else code block
bitmap=BitmapFactory.decodeStream(url.openConnection().getInputStream());
CODE TO REPLACE THE VARIOUS THUMBNAIL IMAGES: By the way, this is production code and works perfect.
String PICTURE_URL;
String getPicture = JOFeeds.getString("picture");
if (getPicture.contains("_t.")) {
PICTURE_URL = getPicture.replaceAll("_t.", "_n.");
} else if (getPicture.contains("_a.")) {
PICTURE_URL = getPicture.replaceAll("_a.", "_n.");
} else if (getPicture.contains("_s.")) {
PICTURE_URL = getPicture.replaceAll("_s.", "_n.");
} else if (getPicture.contains("_q.")) {
PICTURE_URL = getPicture.replaceAll("_q.", "_n.");
}
Note: However, in some cases, like a Video preview or a Link preview, it will not always have a bigger image available. Nothing much you can do about it nor can Facebook I suspect. These typically come from posts that are shared by users from other websites.

Categories

Resources