Extracting url by specifying a keyword - java

I want to extract url of a facebook page by giving a keyword. Eg if I specify a keyword like "gulab jamun" on facebook can I get the url of that page.I tried different ways but I don't even know that is it possible. So can anyone help me for resolving this issue.I tried that using existing API's too restfb and facebook4j but I think it's not possible through that. can any one help me

I think you'll have no success with how you tried it... The RegEx should be passed where?
A solution might be to use the Search API for Pages (https://developers.facebook.com/docs/reference/api/search/#types), for example like this:
https://graph.facebook.com/search?q=gulab+jamun&type=page&access_token={YOUR_APP_ACCESS_TOKEN}
Then you can filter the results for the Page names of interest. To get the URL, you need to request the Page details per Page as follows:
https://graph.facebook.com/{PAGE_ID_FROM_RESULT}?fields=id,name,link
A one-step solution is as far as I know not possible.

Related

Url with tenant id on it, alternatives to pass it as a param?

I'm trying to map an url like www.host.com/{tenant-id}/home to something like www.host.com/home.xhtml?tenantId={tenant-id} where "tenant-id" is the name of the tenant that is using the app, and could be almost anything.
After some research I found many alternatives, but none of them convinces me. I'll list the alternatives so maybe I can help anyone and get some feedback on missing alternatives at the same time.
Furthermore, my app is written in java.
Pretty Faces (or Rewrite). http://www.ocpsoft.org/prettyfaces/
Htmleasy (Resteasy) https://github.com/voodoodyne/htmleasy
A filter, handmade.
URL rewrite trough proxy (Apache / HaProxy)
I tried pretty faces and get it to work. But I'm concerned about some performance issues with high load. I don't know what PF do internally, and I'm afraid that processing every request and applying filters could be bad.
A handmade filter, would be impossible to maintain.
Does anyone have experience with Htmleasy?
Do you know any other alternative?
Thanks in advance
Cristian.
Not sure if I can get a right approach for Java. I am from a .Net background. If this were given to me, i would like to create a httpmodule that intercepts each request and then translates the uri accordingly. However, it will not be required to enable the tenant code in the uri for each request, I would suggest that you initially create a tenant context from within your app and then use it for tenant identification.
This will be far more secure and easy than handling the uri changes per request.
HTH

Passing session information with WebObjects

My team's lead developer is trying to figure out a way to pass session information in some other way than via the URL when using WebObjects.
Our site was built using web objects, but the problem we're now having is that when bloggers blog about us and post links from our site in their blog posts, the URL typically includes session information it and isn't valid for anyone other than the person who copied the link in the first place, Bloggers trying to point people to www.example-dot-com are instead blogging links such as
www.example-dot-com/cgi-bin/WebObjects/example.woa/wo/0.11.3.8
Anyone have any suggestions? Thanks!
There are a couple of issues here. Firstly, if you want to remove the session ID from the URL (which is the default), you override WOSession.setStoresIDsInCookies() to return true and WOSession.setStoresIDsInURLs() to return false.
However, your example URL doesn't have a session ID, so presumably you've figured that out. There are then a number of ways to get friendlier URLs, the easiest of which is probably to use direct actions. You could then have a URL more like www.example-dot-com/cgi-bin/WebObjects/example.woa/wa/someTarget.
Finally, Project Wonder provides full support for URL re-writing, to the extent that you could have something more like www.example-dot-com/someTarget.

Simple check URL of Google safe browsing for Android?

I'm building an Android application which allows people scan QR code and open its content if that is a URL. But before opening, I want to check it's a safe URL. I check Google Safe Browsing API, and it turns out I need to download and save malware and infected URL list, which's impossible for Android client.
There's another way with http://www.google.com/safebrowsing/diagnostic?site= but this have two disadvantages:
1.It doesn't work with full URL or URL paramater:
Work: http://www.google.com/safebrowsing/diagnostic?site=http://example.com
Don't work: http://www.google.com/safebrowsing/diagnostic?site=http://example.com/abc/def?ghi=opq
2.It opens a web page which tell us URL is safe or not, but I'd rather want it return a HTTP status code: like 201 -> safe, 202 -> isn't safe (which is easier to process).
The first disadvantage's not much a problem, but the second's really annoying. Can anyone show me another way around? Really thank.
There is an API that maybe solves all of your problems: http://code.google.com/apis/safebrowsing/
And here is an Java client implementation for it: http://code.google.com/p/jgooglesafebrowsing/
One thing I would suggest is to have a server side implementation and have an Rest api exposed. Your android app can act as a client for the same
You need to urlencode your URL as you cannot have two ? characters in the URL at the same time.
So your URL should looks like:
https://transparencyreport.google.com/safe-browsing/search?url=http:%2F%2Fexample.com%2Fabc%2Fdef%3Fghi%3Dopq
In Java, you can use URLEncoder.encode().
See: Java URL encoding of query string parameters

Redirect or forward in web application

Hi All
I have a requirement like, from some web page on some event user will redirect to MyApp's login page with some parameter. I want to test MyApp is able to get that parameter or not. To test that i made another app in which i am using (code is below ). But this is showing parameter in url which i don't want. I also want to know what other ways are there to redirect/forward to some another url with parameter ( parameter should be hidden hiddn ).
<%
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.setHeader("Location","http://localhost:8080/MyApp/login/login.jsf?user_id=inc&reference_id=123456789");
%> THANKS
It's not possible to do POST redirects, so you can't just redirect with a POST from your scriptlet.
What you can do is:
Build an HTML form in POST with the parameters that you want to pass, but remember, the POST perceived security is brittle, since with a tool like firebug anyone can see those variables (or they can just look at the html source).
A way around the problem is use encryption or one time passwords (that last for a session). I used this way, to connect seamlessly a Java application with PHP. If you're interested I could look it up and share the details of that solution.
First of all, do not use scriptlets. If you dont want to see the parameter in the URL, don't send it with the URL. You can do a POST submit or pass it as a hidden variable from your page.

getUrl using Java

Is there a way of getting the websites absolute URL (http://www.domain.com/) using Java? because I've googled a bit but I only come across with having to make 2 or 3 classes to create that function =/
Update:
The thing is I am trying to create a crawler that will give me some information and among that I'd like to get the URL of the webpage it's getting the information from. I'm developing this in JAVA and what I meant to say was that I was wondering if there was some getUrl(); or any method like that to get me the Url, because I know it can be done but I've only done it writing a whole other class to retrieve the url and then inherit it and use it further...hope it made it clearer
I'm assuming you just want the domain from a JSP, however you may find you need the entire URL including the prefix, domain, path and parameters. The easiest way to get this quickly is to use the Request object and build it. Have a look here for more info:
http://www.exforsys.com/tutorials/jsp/jsp-request-object.html
Here is Sun's API on the HttpServletRequest interface:
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html
The question is not really clear, but I'll make the assumption that you are trying to get the path from within a Servlet.
String realPath = getServletConfig().getServletContext().getRealPath(relativePath);
Could you be more specific? Your question states:
Is there a way of getting the websites
absolute URL (http://www.domain.com/)
using Java?
By "the website" which website are you asking for? I can see multiple ways of interpreting your question:
Given a URL, if there a way to get the hostname portion of it?
Given a relative path, how do you get the full path?
Within the context of a Servlet, is there a way to get the name of the deployed server?
etc...

Categories