Spring social - facebook - validate if user uploaded photo - spring

I'm using Spring Social and I create the Facebook Connection, I'm able to retrieve user's profile picture, but in case the user doesn't have a profile picture the result is default facebook user profile picture. How to determine if user has a uploaded photo ?
Facebook facebookApi = (Facebook) connection.getApi();
facebookApi.userOperations().getUserProfileImage(250, 250);
I looked for every available methods and there is nothing nor any data which allow me to determine this.
How to solve this ?

If you have connection, you can upload image from url:
String imagUrl = connection.getImageUrl();
URL url = new URL(imagUrl);
BufferedImage image = ImageIO.read(url);
To change dimension of uploaded image you can use "type" imagUrl += "?type=large";

Related

How to upload image to Google Drive using MIT APP Inventor II

I'm trying to upload selected image by MIT App Inventor II. What I did is to download an extension which encodes image to base64 coding, and then call Web1 to address Google App Script. Actually, what I did is just follow an YouTube channel, but somehow it does not work.
function doPost(e) {
var data = Utilities.base64Decode(e.parameters.data);
var blob = Utilities.newBlob(data,e.parameters.mimetype,e.parameters.filename);
var folderid = Utilities.base64Decode(e.parameters.folderid);
DriveApp.getFileById(folderid).createFile(blob);
return ContentService.createTextOutput("Your File Successfuly Uploaded");
}
Combining with Taifun's Extension. These blocks are confirmed to be able to do as below.
Display the ImagePicker selected image on the Image component
Encode the ImagePicker selected image to a Base64 string.
Send the string to URL (Google App Script)

How to access a Google Photos shared album

I posted this as an answer to a related question but it was deleted by a moderator, so I'm posting this now as a question. The related question is
Accessing shared albums from Google Photos
I am trying to access a Google Photos shared album using JavaScript. Public albums created with Picasa are easier to deal with using the Picasa Web Albums Data API.
I've developed a peculiar solution parsing the HTML contents of a shared album URL, such as
https://photos.google.com/share/<album>?key=<key>
The parsing function is
function getgooglephotos2(result)
{
var r2 = result.substr(result.search("AF_initDataCallback\\("));
var r3 = r2.substr(0, r2.search("https://video"));
var img = r3.search("https:");
while (img != -1) {
var r4 = r3.substr(img);
var imgend = r4.search("\"");
var r5 = r4.substr(0, imgend);
// r5 contains an image url
r3 = r4.substr(imgend);
img = r3.search("https:");
}
}
I would prefer a cleaner approach. Any idea?
Thanks.
PS: it seems that using authentication, I can reach a Google Photos shared album, but I am trying to implement a solution that doesn't require authentication for shared (public) albums. Here's a link
https://adodson.com/hello.js/demos/albums.html
A simpler approach to test this is
Authenticate on picasa and fetch your userid
https://picasaweb.google.com
After authentication you will reach
https://get.google.com/albumarchive/<userid>?source=pwa
Get your album list using the Picasa Web Albums Data API
https://picasaweb.google.com/data/feed/api/user/<userid>
I'm just developing app that doesn't require authentication. Anyway somehow you need to point out which album should be displaying. In my project I'm using Firebase to store URLs to shared albums. Then I request the URL and get photos using regex. To retrieve the photos I used this tutorial:
https://medium.com/#ValentinHervieu/how-i-used-google-photos-to-host-my-website-pictures-gallery-d49f037c8e3c
At the moment there is no way to access shared albums directly from Google Photos without authentication.

Facebook SDK iOS share photo ( FBSDKSharePhotoContent ) can not share applink

I'm trying to share a photo using FBSDKSharePhotoContent and make the applink works but I bang my head to make it works.
My app is mobile only so the photos are not hosted on any web site.
I use this code to share the photo:
let photo = FBSDKSharePhoto()
photo.image = currentHeaderImage
photo.userGenerated = false
let photoContent = FBSDKSharePhotoContent()
photoContent.photos = [photo]
photoContent.hashtag = FBSDKHashtag(string: "#Showflix")
photoContent.contentURL = NSURL(string: "applink...")
FBSDKShareDialog.showFromViewController(self, withContent: photoContent, delegate: nil)
I generated the applink using the Facebook Developer site interface.
The photo is corretly published on Facebook but there are no link in the post. If I click on the photo it only open a normal photo on facebook.
I tried also using photo.imageUrl, I tried also FBSDKShareDialog without success.
All I need is to share a photo on Facebook user wall and if someone clicks on this photo it should propose to open it in the mobile app.
Thanks for help

Image doesn’t load consistently from Azure blob storage

I am having an erratic problem using Azure blob storage where my images do not load consistently. The problem is that sometimes when I load a web page, the browser will not show the image, but if I refresh it will load correctly.
When the image doesn't load, the browser shows the default image placeholder. Here is an example:
If I check the hyperlink for the image placeholder, I find that it is the same as the when the image loads successfully, except the Shared Access Signature is different.
Sometimes the same image will fail to load for one link but load successfully for another link even in the same page and same page load. The only difference in the URL is the Shared Access Signature.
Here is my code to build the URL with the shared signature
// Get reference to blob (file) that is to be downloaded
blob = blobContainer.GetBlobReference(blobURL.ToString());
// Get shared access signature to download file from azure blob (valid upto "active duration" minutes) from now
signature = blob.GetSharedAccessSignature(new SharedAccessPolicy()
{
SharedAccessStartTime = null,
SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(60),
Permissions = SharedAccessPermissions.Read
});
// Append signature query string to blob / file that is to be downloaded
downloadURL = string.Format("{0}{1}", blob.Uri.AbsoluteUri, signature);
This is the final HTML image link on the web page, i.e. if I show source on the web page in the browser:
<img alt="Profile Picture" src="https://mystorageaccount2.blob.core.windows.net/abcdefg1-hi23-40b5-86de-a20b568f5626/1601/1234d664d1b74ce1aebf4403e5b74af7.jpg?se=2015-10-31T11%3A38%3A39Z&sr=b&sp=r&sig=SaiUToJg%5Ab3zcdef8EeOq84urHf6HQqS%2BAFt1dEQMNI%3D">
Has anyone else seen this problem? Any recommendations on what I might be doing wrong?
I suspect this could be related to the expiry period which you have set on your image blob's shared access signature (SAS). Is there any good reason where you need to set the SAS to 1 minute when you have set it's permission to read-only?

Attach image using Twitter Share link

Is it possible to attach an image to a tweet using the Twitter share link?
I'm using the following url to tweet but I can't find away to attach an image. The tweet has a link to the image but I want it attached to the tweet so someone can view the image while reading the tweet.
https://twitter.com/intent/tweet?hashtags=MyTag&url=http%3A%2F%2Ftest.com%2Fimage.png
Or would have to use the twitter api?
I would recommend using https://tweetinvi.codeplex.com/documentation which you can programmer directly with twitter.
// Publish with media
byte[] file = File.ReadAllBytes(filePath);
var tweet = Tweet.CreateTweetWithMedia("I love tweetinvi", file);
var imageURL = tweet.Entities.Medias.First().MediaURL;
// Publish with geo information
var tweet = Tweet.CreateTweet("Hello guys");
tweet.PublishWithGeo(-54.73, -64.2);
// Retweet
tweet.PublishRetweet();
I do not believe it is possible to upload media through the share link. Probably, a security decision by Twitter.
I suggest you try the twitpic API.

Resources