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

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.

Related

How to use sagemaker java API to invoke a endpoint?

I was trying to run this example: tensorflow_abalone_age_predictor_using_layers
, in which abalone_predictor.predict(tensor_proto) is used to call the endpoint and make the prediction. I was trying to use the java API AmazonSageMakerRuntime to achieve the same effect, but I don't know how to specify the body and contentType for the InvokeEndPointRequest. The document is not in detailed abou the format of the request. Greatly appreciate any piece of help!
I have not tried the specific example but the below snippet should help you to invoke the endpoint for predictions
InvokeEndpointRequest invokeEndpointRequest = new InvokeEndpointRequest();
invokeEndpointRequest.setContentType("application/x-image");
ByteBuffer buf = ByteBuffer.wrap(image);
invokeEndpointRequest.setBody(buf);
invokeEndpointRequest.setEndpointName(endpointName);
invokeEndpointRequest.setAccept("application/json");
AmazonSageMakerRuntime amazonSageMaker = AmazonSageMakerRuntimeClientBuilder.defaultClient();
InvokeEndpointResult invokeEndpointResult = amazonSageMaker.invokeEndpoint(invokeEndpointRequest);
I see the example you are trying creates a TensorProto and passes to the endpoint request. You can try to create a TensorProto of your invoke request and set as the body
Just figured I can override the input_fn to convert the request body string to something can be fed to the model, in this case a TensorProto object.

Web api is giving error on passing * as the input value to the api method parameter

I am using asp.net mvc web api and i have this method
[HttpGet]
public LoginResult AuthenticateOnlineBookingUser(String userName,String password)
{
//My Code
}
The problem is that when i pass (*) as input value to the parameter (password)
i receieve this error but on other inputs it is working perfectly
A potentialy dangerous Request.Path.value was detected from client(*)
Thanks in advance
Note:My client side is written in angular js
i tried this solution as well Getting "A potentially dangerous Request.Path value was detected from the client (&)" but it is not working for me
You need to set the options for invalid characters. You can do this in your web.config as shown here.
Use url encoder to encode the request before sending it to server.
Finally solved my problem by changing my GET request to POST request The problem was with query string in Order to solve it with GET Request i have to make some changes to my query string in order to make it work but

Cannot access Google Geocoding API response object

my first message :)
well, i am trying to write a weather Spa with angular.
as part of the model , i need to grab the location Lat and Lon so im using google geocoding api.
after using $resource.get i am successfully getting the object from google but cant access it.
here is my code :
weatherApp.controller('forecastController'['$scope','location','$resource',function($scope,location,$resource){
$scope.toGoogle = location.toGoogle;
$scope.resource = $resource('http://maps.googleapis.com/maps/api/geocode/json?');
$scope.georesult = $scope.resource.get({address:$scope.toGoogle,Key:"somekey"})
console.log(angular.fromJson($scope.georesult));
}]);
$scope.toGoogle is just a var holding the address which needs to be translated into x and y
the thing is - i am getting a response with the object i was expected, but when i am trying to access it with:
console.log(angular.fromJson($scope.georesult.results[0].geometry.location.lat));
I am getting "TypeError: Cannot read property '0' of undefined"
(Please note that i have already transformed the Json into regular object with Angular.fromJson);
Any suggestions ? thanks in advance.

How can i execute fql command by using restFB or facebook4j

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.

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

Resources