<- Back to Factery API Documentation
Check out our FactFinder prototype here
find
Returns relevant facts and enclosing context for a query term and a set of URLs. Facts are denoted as "simple" items. When enclosing context for a fact is available, it will be returned as a "container" item.
URL:
http://factfinder.facterylabs.com/find.[format]
Request Format:
json
Reply Formats:
json, xml
HTTP Method:
POST
URL Parameters:
- query: (String) The query, URL encoded.
- timeout: (Integer) Timeout in seconds. Defaults to 7200.
- callback: (String) "json" or "xml". Defaults to json.
**Note that any URL parameter can also appear within the POST data. If the parameter appears in both, the URL parameter will take precedence.
Request Format:
http://factfinder.facterylabs.com/find.json?callback=json
POST data:
{ "query": String,
"timeout": Integer,
"urls" : [
{ "url" : String, // target URL
"anchor" : String, // main inbound anchor (crawl or webmap data)
"author" : String, // link recommendation author
"rank" : Integer // relative rank (usually a domain rank)
}
]
}
Response Format:
{ "query": String,
"language": String,
"timestamp": String,
"rank": Integer,
"tag-list": [ //coming soon
{ "href": String,
"tag": String
}
],
"keyval-list": [ //coming soon
{ "key": String,
"value": String
}
],
"items": [
{ "type": String ("simple" or "container"),
"id": Integer, // Only present on "type" = "container" objects.
"container-id": Integer, // Only present on "type" = "simple" objects that are part of a container.
"titles": [ String, String .. ],
"content": String,
"link": String,
"rank": Integer,
"keyval-list": [
{ "key": String,
"value": String
}
]
}
]
}
Sample java code using a static set of URLs:
//begin TestUrlPost.java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import junit.framework.TestCase;
public class TestUrlPost extends TestCase {
@Override
public void setUp() {
}
public void tearDown() {
}
public void testUrlPost() throws Exception {
try {
String data = "content={"+
"\"query\": \"news\"," +
"\"timeout\": 10," +
"\"urls\" : [" +
"{ \"url\" : \"http://news.cnet.com/8301-13860_3-10399578-56.html?tag=newsLeadStoriesArea.1\"" +
"}" +
"]" +
"}";
System.out.println("data = " + data);
// Send data
URL url = new URL("http://factfinder.facterylabs.com/find.json?callback=json");
URLConnection conn = url.openConnection();
conn.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded" );
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
wr.close();
rd.close();
} catch (Exception e) {
System.out.println("Some error occurred " + e);
}
}//end testUrlPost
}
//end TestUrlPost.java
Sample php code using a static set of URLs:
testfactfinder.php
Sample php code using Factery's TwitterFact API to generate dynamic set of URLs to pass to the FactFinder API:
factfinderproxy.php
Comments (0)
You don't have permission to comment on this page.