How can i execute fql command by using restFB or facebook4j - restfb

I want to try this FQL command by using facebook4j:
SELECT message, comments.comment_list.text, like_info.like_count
FROM stream WHERE (source_id=124707154243128) and ( strpos(lower(message), "iphone 6")>=0 or strpos(lower(message), "s6")>=0)
Console display : fql is deprecated for versions v2.1 and higher. I cant change version of facebook API
I tried this but the same error occur
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setRestBaseURL("https://graph.facebook.com/v2.0/");
FacebookFactory ff = new FacebookFactory(cb.build());
Facebook facebook = ff.getInstance();
You guys can help me for getting data from this command by using restFB or facebook4j. Thank you

With RestFB this should be (code untested):
FacebookClient fbc = new DefaultFacebookClient(accessToken, Version.VERSION_2_0);
List<JsonObject> objList = fbc.executeFqlQuery(fqlQuery, JsonObject.class);
The JsonObject is the generic type. Normally you can use a RestFB type, in your case the generic type is more suitable.

Related

I am using AutoJsContext in geckobrowser with that I am using evaluate scrpit. But now i am using webview2 is there a how can i get this

I am using AutoJsContext in geckobrowser with that I am using evaluate scrpit and asble to get data. But now i am using webview2 is there a how can i get this.
Gecko browser:
using (AutoJSContext context = new AutoJSContext(browser.Window))
{
var userIdResult = context
.EvaluateScript("userId", (nsIDOMWindow)browser.Window.DomWindow);
}
Above is the code I use in gecko browser. now i need to get user id from webview2. Please help me in this issue
I am not able to get any alternative
You can use CoreWebView2.ExecuteScriptAsync to inject script into the current top-level document of the WebView2 and receive the result as a JSON string. The method doesn't have a way to specify an execution context. Script is executed in the global context of the top-level document similar to running script in the console of DevTools in the browser.
For example something like the following:
var resultAsJSON = await coreWebView2.ExecuteScriptAsync('window.userId');

com.restfb.exception.FacebookOAuthExceptioni when trying to get page insights using restfb api

Error:
Received Facebook error response of type OAuthException: Invalid parameter (code 100, subcode 1504016)
Code:
FacebookClient facebookClient = new DefaultFacebookClient(accessToken, Version.VERSION_2_5);
Connection<Insight> insights = facebookClient.fetchConnection("3954569608XXXX/insights", Insight.class,Parameter.with("since", "2016-08-01"),Parameter.with("until", "2017-03-10"));
I don't think we can directly give them as Strings. Convert that into datetime. I think, that will do it.

Solr 4.3.1 Data-Import command

I'm currently using Solr 4.3.1. i have configured dih for my solr. i would like to do a full import through command prompt. I know the url will be something like this http://localhost:8983/solr/corename/dataimport?command=full-import&clean=true&commit=true is there any method i can do this without using curl ?
Thanks
Edit
string Text = "http://localhost:8983/solr/Latest_TextBox/dataimport?command=full-import&clean=true&commit=true";
var wc = new WebClient();
var Import = wc.DownloadString(Text);
Currently using the above code
Call it like a normal REST url that's it !! I am using it in my application for importing and indexing data from my Local drive and it just works fine ! :) . Use HttpURLConnection to make a request and capture response to see whether it was successful or not . You don't need any specific API to do that . This is a sample code to make a GET request correctly in C# .Try data import handler url with this, it may work !
Console.WriteLine("Making API Call...");
using (var client = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }))
{
client.BaseAddress = new Uri("https://api.stackexchange.com/2.2/");
HttpResponseMessage response = client.GetAsync("answers?order=desc&sort=activity&site=stackoverflow").Result;
response.EnsureSuccessStatusCode();
string result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine("Result: " + result);
}
Console.ReadLine();
}
}
}
You'll have to call the URL in some way - Solr only operates through a REST API. There is no command line API (the command line tools available just talk to the API). So use your preferred way to talk to a HTTP endpoint, that being curl, wget, GET or what's available for your programming language of choice.
The bundled solrCli application does not have any existing command for triggering a full-import as far as I were able to see (which would just talk to the REST API by calling the URL you've already referenced).

go-endpoint Invalid date format and method not found

Hy, I have some problems with the Go endpoints and Dart client library.
I use the Go library https://github.com/crhym3/go-endpoints and the dart generator https://github.com/dart-lang/discovery_api_dart_client_generator
The easy examples works fine. But they show never how to use time.Time.
In my project, I have a struct with a field:
Created time.Time `json:"created"`
The output in the explorer looks like this:
"created": "2014-12-08T20:42:54.299127593Z",
When i use it in the dart client library, I get the error
FormatException: Invalid date format 2014-12-08T20:53:56.346129718Z
Should I really format every time fields in the go app (Format Timestamp in outgoing JSON in Golang?)?
My research come to that the dart accept something:
t.Format(time.RFC3339) >> 2014-12-08T20:53:56Z
Second problem, if comment out the Created field or leave it blank. I get a other error:
The null object does not have a method 'map'.
NoSuchMethodError: method not found: 'map' Receiver: null Arguments:
[Closure: (dynamic) => dynamic]
But I can't figure it out which object is null. I'm not sure if I'm using the Dart client correct
import 'package:http/browser_client.dart' as http;
...
var nameValue = querySelector('#name').value;
var json = {'name':nameValue};
LaylistApi api = new LaylistApi(new http.BrowserClient());
api.create(new NewLayListReq.fromJson(json)).then((LayList l) {
print(l);
}).catchError((e) {
querySelector('#err-message').innerHtml=e.toString();
});
Does anyone know of a larger project on github with Go endpoint and Dart?
Thanks for any advice
UPDATE[2014-12-11]:
I fixed the
NoSuchMethodError
with the correct discovery url https://constant-wonder-789.appspot.com/_ah/api/discovery/v1/apis/greeting/v1/rest
The problem with the time FormatExcetion still open, but I'm one step further. If i create a new item, it doesn' work. But if I load the items from the datastore and send it back, this works.
I guess this can be fixed with implementing Marshaler interface, thanks Alex. I will update my source soon.
See my example:
http://constant-wonder-789.appspot.com/
The full source code:
https://github.com/cloosli/greeting-example

System.Net.HttpWebRequest Does not contain a definition for 'GetResponse' . In Grid App(XAML)

Following code worked perfectly in Console Application in making request and getting response using HttpWebRequest and WebResponse:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.google.com");
WebResponse response = request.GetResponse();
But the same code when written in GridApp(XAML) template, GetResponse() method gave error:
System.Net.HttpWebRequest Does not contain a definition for 'GetResponse' ...
How come? I included HtmlAgilityPack and all using statements. Does WPF/WindowsStoreApp support slightly different version of GetResponse Method? What am I missing?
In case it is a Windows Store App (and not WPF) there is no synchronous GetResponse method in class WebResponse.
You have to use the asynchronous GetResponseAsync instead, e.g. like this:
using (var response = (HttpWebResponse)(await request.GetResponseAsync()))
{
...
}
If you take a look at the WebRequest page, you'll see that some members are marked with a green icon (a suitcase?). Those are "Supported in .Net for Windows Store apps".

Resources