getting page info from a webpage while sharing facebook style
- by user556167
Hi all. I am writing an app to share a page to friends when browsing. To this end, I can get the url of the page to my app and display it on the screen. Could anyone tell me, how to improve this, to show the headline of the page and the picture of a page as it appears when a page is being shared to friends on facebook.
Here is the code to get and display the url of the page:
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
String mNewLinkUrl="";
if (action != null && type != null && Intent.ACTION_SEND.equals(action) && "text/plain".equals(type)){
mNewLinkUrl = intent.getStringExtra(Intent.EXTRA_TEXT);
}
TextView ptext = (TextView) findViewById(R.id.pagetext);
ptext.append("\n"+mNewLinkUrl);
Any insight will be appreciated.
//update 1
found a method:
use Jsoup to download the html as a Document.
And use Elements and Element to get the data.
For eg, the following is the code to get the links in imports in the html page:
Elements imports = doc.select("link[href]");
for (Element link : imports) {
Log.d(TAG,"link.tagName()"+link.tagName()+"link.attr(abs:href)"+link.attr("abs:href")
+"link.attr(rel)"+link.attr("rel"));
}
But I am not able to figure out what attributes facebook exactly gets.
Can anyone help me in this?
Thank you.