I'm trying to get public events from Facebook Graph API with the following code:
val request = GraphRequest.newGraphPathRequest(
AccessToken.getCurrentAccessToken(),
"/search",
GraphRequest.Callback { response : GraphResponse ->
Log.e("E", response.toString())
}
)
val parameters = Bundle()
parameters.putString("q", "Toronto")
parameters.putString("fields", "city,state,country,description,id,start_time,end_time,name,place,street,zip")
parameters.putString("type", "event")
parameters.putString("limit", "25000")
request.parameteans = parameters
request.executeAsync()
But I'm getting an empty data array. When I change the "type" field from "event" to "place" then I actually get the data.
Why am I getting no data for the event?
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
You can no longer use the /search endpoint with the following object
types:
event
group
page
user
Related
I have a lambda, written in Java, that accepts a Request Object of the structure
{
"id": "be1c320a-144f-464d-b32c-38ec7fb4445b",
"userId": "foobar"
}
When I call this Lambda through the test interface with such an object, it works fine.
I want to create an API where a GET request to
/users/foobar/items/be1c320a-144f-464d-b32c-38ec7fb4445b
i.e. of the form
/users/{userId}/items/{id}
calls this Lambda.
I have created the API resources /users, {userId}, items, and {id} appropriately.
And I have created the GET method (on /users/{userId}/items/{id})and associated it to the lambda.
When I test the API, it invokes the lambda, but with null values in the request. I can see it package the path as {"id":"be1c320a-144f-464d-b32c-38ec7fb4445b","userId": "foobar"} in the logs, but that's not being sent in the body.
I have tried creating a template map (and have tried RTFM), but cannot see how to map path parameters to a body.
How do I achieve this mapping?
I think your Request Object structure may not be properly configured. There may be a few ways to configure this. Here is some information that has helped me.
How to pass a querystring or route parameter to AWS Lambda from Amazon API Gateway - Demonstrates this mapping (albeit with python). However, taking the top response, if you enable "Use Lambda Proxy integration", you can similarily do this with Java as so:
#Override
public Object handleRequest(APIGatewayProxyRequestEvent input, Context context) {
Map<String, String> pathParameters = input.getPathParameters();
String id = pathParameters.get("id");
String userId = pathParameters.get("userId");
// Handle rest of request..
}
This is a tuturial using the serverless framework to create an Api with Java. This tutorial similarily accesses the pathParameters by parsing the input rather than using the APIGatewayProxyRequestEvent java class.
#Override
public Object handleRequest(Map<String, Object> input, Context context) {
try {
// get the 'pathParameters' from input
Map<String,String> pathParameters = (Map<String,String>)input.get("pathParameters");
String id = pathParameters.get("id");
String userId = pathParameters.get("userId");
} catch (Exception ex) {
logger.error("Error in retrieving product: " + ex);
}
}
Use a mapping template.
First, in the Method Request section, you should see userId and id as Request Paths
Then, in the Integration Request, do not choose Proxy Integration.
Then in the Mapping Templates section, add a new mapping template for application/json of the form
{
"id" : "$method.request.path.id",
"userId" : "$method.request.path.user_id"
}
I have a client application requesting a list of channels from a webservice. Is it possible to take the "response" from the web service and store it in an ArrayList?
Meaning if I wanted to store a list of channels for example, it would normally come from the web service as a response, typically from ResponseBuilder.
And I want to store it in an ArrayList from the client, like List.
How would I go about doing that?
You can use TypeReference to instantiate your Channel object list, here is an example:
import com.fasterxml.jackson.core.type.TypeReference;
public class ChannelClient {
public void getChannels() {
Response serviceResponse = client.target("http://your_service_url/channels/").
request(MediaType.APPLICATION_JSON).get(Response.class);
String responseString = serviceResponse.readEntity(String.class);
List<Channel> list = new ObjectMapper().readerFor(new TypeReference<List<Channel>>() {
}).readValue(responseString);
}
}
Make sure to have Jersey JSON Jackson jar in your dependencies, you can get it from here
https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-json-jackson/2.26-b07
EDIT: In case you want to consume MediaType.TEXT_PLAIN response, you will just change the request method argument to your specified type like this:
Response serviceResponse = client.target("http://your_service_url/channels/").
request(MediaType.TEXT_PLAIN).get(Response.class);
i have an ASP.NET Core 1.1 WebApi Endpoint like this one:
[ApiVersion("1.0")]
[Route("api/[controller]")]
public class SampleController : Controller
{
[HttpGet]
public IActionResult Get()
{
...
}
}
It returns a collection of 'Sample'-Objects to the caller.
Now i do like to send within the Request Header a Custom Attribute like 'App-Type' which let the Endpoint know which App asks for Data. But what is to do that the endpoint fetches this Attribute so that i have it as variable within the function?
If you want a parameter in a controller action that reads from the headers, you should use [FromHeader] attribute, in your case it will be like [FromHeader(Name="Accept-Language")]. More information in https://learn.microsoft.com/en-us/aspnet/core/mvc/models/model-binding
I'm struggling with the batch request to the Facebook API in React Native. For a single request this tutorial works fine : https://github.com/facebook/react-native-fbsdk.
But can I create a batch request. Using GraphRequestBatch does not seem to work. Adding up request with addRequest() neither (such as suggested in https://github.com/facebook/react-native-fbsdk/issues/185).
Please help! I would like to send a batch of request with the same node and same edges, excepts only the time span changes.
Each request will look like :
const request = new GraphRequest('me/',
{
accessToken: accessToken,
parameters: {
fields: {
string: 'posts.since(t1).until(t2).limit(n){likes.summary(true)}'
}
}
},
responseInfoCallback);
I tried creating several requests, each with a different t1 and t2, then add them up like this :
const graphmanager = new GraphRequestManager().addRequest(requesta);
graphmanager.addRequest(requestb);
...
graphmanager.start();
But only the first request gets executed.
Thanks for the help!
Suppose all that happens initially in a client swf is a user clicks a hyperlink in a text object of the swf, so this requests a "page" from the server. In response the server just modifies that existing swf in the client browser, by for example (?) invoking public functions of it, and possibly passing in as parameters the name of image or data files which were also downloaded in response to the URL request. The crucial part is that all that can happen initially in the SWF is a URL "page" request. Is this commonly done and if so, how.
Clicking on an hyperlink in AS3 will trigger a TextEvent.LINK event, you can then listen to this event and in your function proceed to call the relevant service which in turn will send you a response which you can use to update your swf data.
Check the docs here for the TextEvent class
http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/
Now, it all depends on what your link is, if it loads an XML ,then you can use the URLLoader class to load the XML data
private function init():void
{
var tf:TextField = new TextField();
tf.htmlText = "<a href='http://example.com/data.xml'>Update Data</a>";
tf.addEventListener(TextEvent.LINK, clickHandler);
addChild(tf);
}
private function clickHandler(e:TextEvent):void
{
trace(e.type); // link
trace(e.text); // http://example.com/data.xml
var loader:URLLoader = new URLLoader();
loader.addEventListener( Event.COMPLETE , dataLoaded );
loader.load( new URLRequest( e.text ) );
}
private function dataLoaded(event:Event):void
{
trace( event.target.data );// xml content
//from here you can then parse the XML & update your swf
}