I have the necessary permissions from facebook. I am using RESTFB, I see the methods getFullPicture and getPicture in Post.class but unable to make anything out of it. How to get all the photos from a post on a page in FB, using RESTFB in Java.
GetFullPicture and getpicture are not meant to give all images. To get the images from a post we have to get the post ID. Post id is the combination of pageId and one of the photo's which user has uploaded in that post, that photos id.
Example:242343423_2423423423. So the second part is a photo id. Take that photoId and query for its album. 2423423423?fields=album. will give the albumId. Get all photos from that album. JobDone!
Related
Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, videoLink);
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
I can send the link containing the video to someone on WhatsApp, however, I want to show the image of the video to the user on WhatsApp.
Is there a way to do this in java or kotlin
as in the picture
I am not sure what you're trying to do exactly but there are two options I can think of.
Firstly, if you're looking for something like what you have in the screenshot then no coding is required.
This is usually handled by Facebook when their bot scrapes the meta tags from the page that is shared.
If you wanted to accelerate this process you can manually put the link that you want to share in Facebook's Sharing Debugger and scrape it manually so that Facebook takes note of it.
Once that is done you can share the link and it should display video information including the image, title & description.
However, if you want to share only the video image/thumbnail you can do that as follows:
grab the video ID from the URL using REGEX or by taking a substring of the URL that holds the ID.
Plug that ID in one of the following URLs to get a link to an image that you can share instead of the video.
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/default.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/sddefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
Thanks to #asaph for his details answer on getting Youtube thumbnail here
Is there any way to get the user cover photo via spring-social-facebook?
Something similar to this (used to retrieve the profile picture);
Via AbstractConnection, method getProfileUrl()
Via UserOperations, method getUserProfileImage()
Thanks for the help
From version 2.0.x you can get the cover image using
facebook.userOperations().getUserProfile().getCover()
See javadoc
I am creating an android app that have some page with information read from the sqlite database and a qr code reader built in the app, but i have question to ask
This is my question :
when i read the qr code which contain some IDs, is it possible to link/bring to a particular page that have that IDs ?
I try to google for information about this, but i did not find any sample code or tutorial that teach how to link from qr code to particular part in the android app. From all the google information i found, i only know that i need a url, then how can i generate a url to link to the android app? does it mean that i have to create a website?
MY MAIN IDEA:
in my android app have information:
Page 1:
Apple
cost 1 dollar
Page 2:
Pear
cost 1.50 dollar
What i want to do:
Scan qr code from my android, reader retrieve Page 1 as ID, then link/go to Page 1 in the android app
I just want go to or link to that particular activity1(page1) after scan the qr code that contain 1 within that same app
To open url from android app use this:
String url = "http://www.example.com/YOUR-ID-GENERATED_PAGE";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
source page here on StackOverflow
You can use TEXT format of QR code to return a text rather than a URL. In your case, the returned text could be an ID. Map your IDs with the Activities you are intended to awake after scanning.Then check the ID and start your mapped Activity manually in your application.
Android platform is really fun to work with especially when it comes to resolving issues. Indeed, there is possibly everything there is to know about Android development on the internet.
Alright, I've been searching for about a week and haven't found anything that was close from working. Let's dive into it.
We are building an Android Application that requires a read/write access to existing Contacts on a device. It has become really easy to read a contact's set photo using this method :
// Returns a stream reading a contact thumbnail
public InputStream getContactThumbnail(int id) {
// Stream reading contact image
InputStream stream = ContactsContract.Contacts.openContactPhotoInputStream(
context.getContentResolver(),
ContentUris.withAppendedId(
ContactsContract.Contacts.CONTENT_URI, id
)
);
// If image is null, try to read Facebook image
if (stream == null) {
stream = new ByteArrayInputStream(getFacebookPhoto(id));
}
return stream;
}
Now, the previous method receives an id as a parameter and returns a Stream making it possible to read the contact's thumbnail. It is needed to be a stream because the phone acts like a web server and has multiple threads running. If a thumbnail is requested several times in the same short time lapse, an OutOfMemoryException will be thrown for sure.
I need to correctly implement the getFacebookPhoto(int) method so that it returns whatever stream reading the Facebook profile picture of a contact that has his or her contact linked with his or her respective Facebook profile. I've tried and failed so many times.
Hypothesis #1
If a contact is linked with a Facebook profile, it has to have the Facebook ID saved somewhere. If this information is accessible, it would make it easy to get a Facebook profile picture using graph. Problem is an internet connection is needed to do so.
Hypothesis #2
Facebook thumbnails are saved somewhere on the SD card. Maybe there's a link between a Contact and those files that can be found through an SQLite request?
Hypothesis #3
sigh, I look desperate. Okay, if I understood correctly, a phone Contact and a Facebook Contact are not the same things in the database. If you query all the contacts from the following URI :
*ContactsContract.Contacts.CONTENT_URI*
you only get contacts that you created and nothing regarding Facebook links. Is there a way to find all linked contacts and get their respective photos?
Conclusion
Yeah, that's about is. To sum it up, I need to read all contacts information. For each contact, I have to find its photo. If the user has not set a picture to a contact that is linked to a Facebook profile, the profile picture which it was linked too must be read.
Up until now, the StackOverflow community has been of a great help and saved my life and job countless times. It is possible, I've seen it in other apps.
Thank you for spending of your time, it is truly appreciated.
EDIT
Let's not give up! I will start a 100pts bounty as soon as I can.
Your hypothesises are right to a certain extend. In contact application this things are handled as folows -
Device's Contact & its Facebook account are mapped by Contact's _ID & Facebook's id, this is one-to-one mapping. So from this mapping first you have to find out the Facebook id
of the conserned contact. But in which table this info is stored & wheather that table is eposed to you or not, URL to that table completely dependent on vendors.
From Facebook Id we can get corresponding profile image either from Facebook's server or from Media DB, if it is also cached in.
But this is not supported by all OEMs. And implementation varies from OEM to OEM as Google don't enforce for any common standard implementation of it.
So there is no garantee that a single implementation will work for all devices from different OEMs.
You should really go and play around with Graph Explorer on the Facebook Developers site it will help you a lot in figuring out what you need to do to get certain things. In order to get the picture for an person you just have to do is do a simple GET HTTPRequest with the graph path of /ID?fields=picture (where ID is the facebook id of the contact) which will return a JSON object that contains the link to that person's profile picture. From there it should be fairly simple for you to get the image.
You can also do the same thing to get all of a person's friends with the picture information by sending a GET request to /me/friends?fields=picture. It seems like you are trying to avoid a web connection but if the android contacts do not store the facebook id then you will have to get the ids yourself I'm afraid.
Hope that helps.
Why don't you use FQL, for Android you can use -
String query = "SELECT uid, name, pic, pic_small, pic_big FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";
Bundle params = new Bundle();
params.putString("method", "fql.query");
params.putString("query", query);
mAsyncFacebookRunner.request(null, params, new CustomRequestListener());
where CustomRequestListener() extends RequestListener in the Facebook Android SDK.
I'm trying to post a photo on the wall of a friend using RestFB, a Java API for Facebook. I tried various solutions like:
facebookClient.publish(fbu+"/photos/",FacebookType.class,new FileInputStream(pathOrig));
fbu is the Facebook user id of the friend. This code actually posts the photo on my wall!
facebookClient.publish(fbu+"/feed/",FacebookType.class,new FileInputStream(pathOrig),Parameter.with("message",message));
This code posts the message on my friend's wall, but without the photo.
Strangely, it's possible using directly Facebook to upload photos on friends wall, so it should be possible using Graph, in my opinion...
Any clue?
You can't post a photo on your friends wall. You can, however, upload a photo and tag your friend in it.
According to the Photo Documentation you set the tags on a photo by setting the tags parameter on the graph request, and formatting like so:
[{
"tag_uid": <fb uid>,
"x":74,
"y":62
},
{
"tag_uid": <fb uid 2>,
"x":8,
"y":27
}]
Each object is the has your friend's FBuid and the x and y position of the tag location on the photo.
You can, however, publish a link on your friend's wall to a photo and have the link go off Facebook for them to view it. This is probably not what you're looking to do, but it's an option.