I'm developing a game on Android and want to integrate with facebook, so user can share his results.
I'm using the Open Graph to create the actions, the objects and so on from my app.
Already done some progress using direct Graph API requests like this.
Bundle params = new Bundle();
params.putString("my_object", "http://samples.ogp.me/251143638264597" );
mAsyncRunner.request("me/MY_APP_NAMESPACE:beat", params, "POST",
new WallPostRequestListener(), null);
This way the post is made. But ,as you can see on the code above, i'm using the sample object created by Open Graph.
My problem is: how can i create an object dynamically, in java? It's possible? I've already tried to create a JSON object, but didn't have success.
I saw on the tutorials an HTML metadata, but this is the only way to do it?
Related
I have been stuggeling wiht that for a while and found no working solution:
I want to get a GeoJSON-String from an own ArcGIS Web Server. I want to use the REST-API and got it working in the browser. I just have to type in my username and password and after my authentification i can use the link to get the GeoJSON-String.
In Android I tried it with different solutions, one - of course - was to follow the instructions on the Esri-Website. Here they explain how to set the Username and the Password to create a UserCredential. The UserCredential now is passed to the Method to create a new ArcGISDynamicMapServiceLayer together with the REST-Link. So they get a new Layer, but there is no method, where you can pass the UserCredential and the Link to get just a String.
Because I want to get polygons I thought, that the ArcGISFeatureLayer could help me out. But if I pass the given User-Informations and the Link i just get back an null-Objekt.
Here is a snippet of my most-hopefull code:
String url = "https://domain.de/arcgis/rest/services/FeatureEditor/FeatureEditor/FeatureServer/13/query?where=fahrzeug_id+%3D+21+AND+auftrag_revisionnewest+%3D+1+AND+auftrag_id+%3D+45&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&units=esriSRUnit_Foot&outFields=*&returnGeometry=true&outSR=4326&returnDistinctValues=false&returnIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnZ=false&returnM=false&f=geojson";
UserCredentials creds = new UserCredentials();
creds.setSSLRequired(true);
creds.setUserAccount("username", "password");
ArcGISFeatureLayer featureLayer = new ArcGISFeatureLayer(url,(ArcGISFeatureLayer.Options)null,creds);
So the best would be to get just the GeoJSON-String as accessable with the Link. But how can I access the HTTP with the Username and Password?
If you want to do that style of query within the ArcGIS Android SDK you'll have to do it with creating a FeatureLayer and then using the Query class to define the equivalent of your query string. This gives you back a FeatureSet that contains features which should have the information you're looking for, but it won't be in the form of GeoJSON. There's a toJSON method on the FeatureSet that might give you what you're looking for, but I'm not positive. If you just want a pure JSON response, you're going to have to do the HTTP requests yourself, setting up whatever authentication the REST API needs within your request and then handling the response.
When submitting dialog to Quickblox I add QBDialogCustomData using the code below
QBDialogCustomData qbDialogCustomData=new QBDialogCustomData("UserInfoDialog");
qbDialogCustomData.putString("FBID1", myApp.getFbid());
qbDialogCustomData.putString("FBID2", fbid);
qbDialogCustomData.putString("USERID1", String.valueOf(myApp.getUserID()));
qbDialogCustomData.putString("USERID2", String.valueOf(userId));
qbDialogCustomData.putString("FULLNAME1", myApp.getFullname());
qbDialogCustomData.putString("FULLNAME2", fullname);
dialog.setCustomData(qbDialogCustomData);
However when later using the getCustomData method it returns null, what is missing to submit the QBDialogCustomData, I have the Custom object class created with the right fields so that shouldn't be an issue.
Im using QuickBlox with RESTFUL API and it works for me if I create the dialog first with the custom data/parameters then send a message but before that you must create the custom object in the admin.quickblox site first. Have you tried that method ?
I referred to this link to create the custom object in the admin quickblox site
Link : http://quickblox.com/developers/Custom_Objects#Create_data_schema
I have been reading the Facebook documentation. The Facebook documentation for asking/sending gifts mentioned a YOUR_OBJECT_IDfor this call:
FB.ui({method: 'apprequests',
message: 'Take this bomb and blast your way to victory!',
to: 'RECIPIENT_USER_ID'
action_type:'send',`enter code here`
object_id: 'YOUR_OBJECT_ID', // Where do I get this ?
data: 'Friend Smash Custom Tracking 1'
}, function(response) {
console.log(response);
});
How do I get get it? I have already created my object inside Open Graph, but there is no object id specified. Do I need to initiate a create request for the user from my app for that object or how is this suppose to work?
The request_object_id is what you will get back from the dialog, after the user sent the gift – it is part of the dialog’s return value. It is simply the identifier for the request that was send.
https://developers.facebook.com/docs/games/requests/v2.1#response
You can use it to read details of the request back from the API.
OK, so since this is about the object id that one can pass to the dialog:
That documentation section already links to https://developers.facebook.com/docs/sharing/opengraph/custom, where this is explained in more detail.
Basically, you need to set up your own Open Graph action and Open Graph object. This will define what your object is, and what players of the game can do with it.
Open Graph objects can be created in two ways:
You can host them yourself. To do this, you simply provide URLs to HTML pages which include the Open Graph meta data that specifies the object property values. Facebook will then read the meta data from those URLs (“scraping”). In that case, you would simply pass the object URL to the dialog as object_id.
You can use the Object API to create objects that Facebook will host for you. These can either be “app-owned” or “user-owned” – depends on if the are specific to a certain user, or “common” objects to be used by all users of your app. Creating an object via that API will give you back an object id, that you can then pass to the dialog.
If you are not familiar with the whole Open Graph Story concept yet, then I recommend you start by having a look at the whole Open Graph section, https://developers.facebook.com/docs/sharing/opengraph
I'm implementing a game with turn based multiplayer with google play game services:
https://developers.google.com/games/services/android/turnbasedMultiplayer
My game has some different variations and in order to help users choose easily from the default UI, I would want to add a name for each match.
If it was possible, a player with for example 2 current matches would be able to identify each one easily without opening it.
Thanks.
You could put this information into your Turn data. Like this...
// This is the byte array we will write out to the TBMP API.
public byte[] persist() {
JSONObject retVal = new JSONObject();
try {
retVal.put("data", data);
...
You could then write a custom function to retrieve the match data and you would have to put that information into a custom inbox dialog. I have not done this currently...
This functionality is part of the standard product. Look at the sample from google skeletonTBMP.java and also the skeletonTurn.java (I think it is called). This is where you pass data between turns. It would be fairly easy to populate this into the "data" object which gets updated at each turn, and then display this value on the screen as text. Link here...
https://github.com/playgameservices/android-basic-samples/tree/master/BasicSamples/SkeletonTbmp/src/main/java/com/google/example/tbmpskeleton
This is a theoretical question for the time being as I do not have any code as yet.
As far as I understand fragements they are basically a means of displaying results from an activity, what I am trying to achieve is a automatically updating 'wall' like facebook inside my fragmemt.
Currently I query information from my database from my mainactivity before passing the info to my fragement, as it stands I have only retrieved static content to update an Image and TextView like so:
Intent upanel = new Intent(getApplicationContext(), MainActivity.class);
upanel.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
upanel.putExtra("USER_ID",json_user.getString(KEY_UID));
upanel.putExtra("USER_FN",json_user.getString(KEY_FIRSTNAME));
upanel.putExtra("USER_LN",json_user.getString(KEY_LASTNAME));
pDialog.dismiss();
startActivity(upanel);
Now, how would one achieve a 'live' update, for instance a drag up to update like in the facebook app?
What should I be researching to achieve this?
Edit
In the spirit of asking an actual question, how do you update a fragment from a JSON request in real time?