Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    GiacL
    @GiacL
    it works, ty
    @wenjdu my test was wrong, it created once again with my device id and not the pinDeviceID
    wenjdu
    @wenjdu
    Could you copy paste your code here please
    With markdown if possible
    GiacL
    @GiacL

    ``` (shift+enter for line break)
    var code = "formatted";
    PinDevice pinDevice = new PinDevice("pinDeviceTransport", new MatchMoreLocation(32L,46.52214476,6.64595656) );
    matchMore.createPinDevice(pinDevice, createdPinDevice ->{
    Toast.makeText(getApplicationContext(), "pinDevice créé", Toast.LENGTH_SHORT).show();
    Toast.makeText(getApplicationContext(), "pinDeviceID = " + createdPinDevice.getId(), Toast.LENGTH_SHORT).show();
    this.pinID = createdPinDevice.getId();
    return Unit.INSTANCE;
    }, e -> {
    Toast.makeText(getApplicationContext(), "erreur creation pinDevice: " + e.getMessage(), Toast.LENGTH_SHORT).show();
    Log.d("JavaExample", e.getMessage());
    return Unit.INSTANCE;
    });
    Publication publicationConf = new Publication("conference", 3330d, 3330d);
    matchMore.createPublication(publicationConf, pinID, createdPublication ->{
    Toast.makeText(getApplicationContext(), "Publication créée", Toast.LENGTH_SHORT).show();
    Log.d("TARTATIN", createdPublication.toString());
    return Unit.INSTANCE; // return Unit.INSTANCE; is important (b/c kotlin vs java lambdas differ in implementation)
    }, e -> {
    Toast.makeText(getApplicationContext(), "erreur creation publication: " + e.getMessage(), Toast.LENGTH_SHORT).show();
    Log.d("JavaExample", e.getMessage());
    return Unit.INSTANCE;

        });

    ```

    sorry don't know how it's work markdown
    wenjdu
    @wenjdu
    matchMore.createPublication(publicationConf, pinID, createdPublication ->{
    Toast.makeText(getApplicationContext(), "Publication créée", Toast.LENGTH_SHORT).show();
    Log.d("TARTATIN", createdPublication.toString());
    return Unit.INSTANCE; // return Unit.INSTANCE; is important (b/c kotlin vs java lambdas differ in implementation)
    }, e -> {
    Toast.makeText(getApplicationContext(), "erreur creation publication: " + e.getMessage(), Toast.LENGTH_SHORT).show();
    Log.d("JavaExample", e.getMessage());
    return Unit.INSTANCE;
    it should be working
    what errors messages you get in the log ?
    GiacL
    @GiacL
    got no error message
    The publication is created, but it takes my deviceID and not the pinDeviceID
    when i see the match
    wenjdu
    @wenjdu
    Log.d("TARTATIN", createdPublication.toString());
    then do you see something in the log debug ?
    GiacL
    @GiacL
    04-16 13:35:30.708 8167-8167/ch.giacomolonghi.unilapp D/TARTATIN: Publication(topic=conference, range=3330.0, duration=3330.0, properties={}, deviceId=448af123-5b92-4b2b-b249-160b57434c2b, worldId=null, createdAt=1523878530656, id=07808e0b-7e66-4493-9bf9-550476c0235b)
    wenjdu
    @wenjdu
    deviceId=448af123-5b92-4b2b-b249-160b57434c2b is it the id of your pin ?
    GiacL
    @GiacL
    no it's the id of my device
    wenjdu
    @wenjdu
    matchMore.createPinDevice(pinDevice, createdPinDevice ->{
    Toast.makeText(getApplicationContext(), "pinDevice créé", Toast.LENGTH_SHORT).show();
    Toast.makeText(getApplicationContext(), "pinDeviceID = " + createdPinDevice.getId(), Toast.LENGTH_SHORT).show();
    this.pinID = createdPinDevice.getId();
    return Unit.INSTANCE;
    }, e -> {
    Can you log the pin device id
    and compare
    it shouldn't be your main device id in the publication
    GiacL
    @GiacL

    04-16 13:39:55.432 11508-11508/ch.giacomolonghi.unilapp D/pinid: 40bdeb11-b03a-4823-81bb-33b99e5cfbf2

    04-16 13:39:55.457 11508-11508/ch.giacomolonghi.unilapp D/TARTATIN: Publication(topic=conference, range=3330.0, duration=3330.0, properties={}, deviceId=448af123-5b92-4b2b-b249-160b57434c2b, worldId=null, createdAt=1523878795430, id=6a564909-871f-403b-9920-82df8bd61c3c)

    wenjdu
    @wenjdu
    Can you matchmore.createPublication(yourPublication, "40bdeb11-b03a-4823-81bb-33b99e5cfbf2")
    Try it like that and give me the log again
    GiacL
    @GiacL
    04-16 13:46:21.858 12556-12556/ch.giacomolonghi.unilapp D/TARTATIN: Publication(topic=conference, range=3330.0, duration=3330.0, properties={}, deviceId=40bdeb11-b03a-4823-81bb-33b99e5cfbf2, worldId=null, createdAt=1523879181841, id=2e825852-a1de-41f2-9d10-c46722e6783b)
    wenjdu
    @wenjdu
    ok see you are publishing on the right device id now
    GiacL
    @GiacL
    yeah but i put the String directly, i can't put that in a variable?
    wenjdu
    @wenjdu
    So I think the issue is related with the value you store inside of your variable this.pinID
    GiacL
    @GiacL
    ok, thank you
    wenjdu
    @wenjdu
    Yes you definately can but be careful with the callbacks
    GiacL
    @GiacL
    thanks
    wenjdu
    @wenjdu

    When there is asynchronous calls, you have to make sure that async call One is finished before async call Two is launched. Especially, when you need a value that is returned with async call One.

    In your case, you have pinID which is supposed to be store at the end of the async call One, but if your async call Two is called before async call One is done. Then you will have pinID = null, which lead to the case where createPublication(publication, null) == you create a publication for your main device.

    arthfr
    @arthfr
    Bonjour, quel type d'infrastructure (en terme de serveur) utilisez-vous ?
    Pour un projet universitaire
    elsener
    @elsener
    Bonjour @arthfr, notre service fonctionne dans le Cloud (GCloud) et pour l'utiliser vous n'avez pas besoin d'infrastructure de votre côté. Nos sdks communiquent avec le backend directement. Est-ce que cela répond à votre question?
    Arnaud de Charrière de Sévery
    @Ohmere03

    Hi, I'm trying to make a publication from a server in Java. If I understood correctly, I need to make a post request on your rest api using this url: https://api.matchmore.io/v5/devices/{deviceId}/publications

    Then I need to replace the brackets of the deviceId by my deviceId. However, I still have the following question: how do I structure the header of the request? Do I only need the api key ? or should I put any username and password encrypted too?

    For example taking this code:
    ´´´
    HttpPost createConnectivity(String restUrl, String username, String password)
    {
    HttpPost post = new HttpPost(restUrl);
    String auth=new StringBuffer(apiKey).toString();
    byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("UTF-8")));
    String authHeader = "Basic " + new String(encodedAuth);
    post.setHeader("AUTHORIZATION", authHeader);
    post.setHeader("Content-Type", "application/json");
    post.setHeader("Accept", "application/json");
    post.setHeader("X-Stream" , "true");
    return post;
    }

    ´´´
    Would it be the correct approach for the header?

    Adam Smolarek
    @adamsmo
    there is no need for user and password
    only apiKey
    nico368
    @nico368

    Hello, I'm trying to do the same as Arnaud, But I get a HandShake_Failure.
    This is my code: Do I need to specify authentication somewhere?

    ....
    public class Test {
    public static void main(String[] args) throws IOException {
    URL url = new URL("https://api.matchmore.io/v5/devices/{deviceId}/publications");
    HttpsURLConnection httpCon = (HttpsURLConnection) url.openConnection();
    httpCon.setDoOutput(true);
    httpCon.setRequestMethod("POST");
    OutputStreamWriter out = new OutputStreamWriter(
    httpCon.getOutputStream());
    System.out.println(httpCon.getResponseCode());
    System.out.println(httpCon.getResponseMessage());
    out.close();
    }
    }

    Łukasz Młynik
    @lmlynik
    @nico368 what is your device id?
    Łukasz Młynik
    @lmlynik
    also, yes, you need toto provide your appi key just like @Ohmere03
    you just need to call setHeader("AUTHORIZATION", "<your api key>");
    you don't need to wrap it in any Basic digests
    nico368
    @nico368

    public class AndNico1 {

    public static void main(String[] args) throws IOException {
    
        HttpPost url = new HttpPost("https://api.matchmore.io/v5/devices/a2dee2ed-9996-41cf-af07-996c9a576472/publications");
          String apiKey;
        apiKey = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJhbHBzIiwic3ViIjoiYjBhM2M3ZGQtMGUyMC00MDk3LTkwNmYtYjY0NjA5MzU3Y2VjIiwiYXVkIjpbIlB1YmxpYyJdLCJuYmYiOjE1MjA1MDg5NjcsImlhdCI6MTUyMDUwODk2NywianRpIjoiMSJ9.TzV_vFEjs1XlK5WeSwHnKurYSNrS28qllVaQDg8SEtcfA4AwxtvZSHCPliKkFVouD7nQiStz-rN2Rlh26KObQA";
        url.setHeader("AUTHORIZATION", apiKey);

    }
    }

    I don't have the handshake issue anymore. Thanks

    Simple question, the deviceId, worldId etc. should be in a json file or should they be added as params?

    thanks
    Łukasz Młynik
    @lmlynik
    as specified in the api documentation, not sure what json file are you referring to
    nico368
    @nico368

    in the API documentation, all that is given is this sample:

    {
    "worldId": "string",
    "deviceId": "string",
    "topic": "string",
    "range": 0,
    "duration": 0,
    "properties": {
    "band": "Metallica",
    "tags": [
    "rock",
    "metal"
    ],
    "price": 400,
    "currency": "CHF",
    "free_parking": true
    }
    }

    When creating a publication, do we send this requested Body all in the Header, or in a Json Object, or which way?

    Łukasz Młynik
    @lmlynik
    this is the body
    nico368
    @nico368
    Alright, thanks. I think I got it, Will run a few test and if I have an issue, will come back. Thanks, great support!
    nico368
    @nico368
    Hi, me again, I'm struggling to understand how the server wishes to receive the body. Is it as a json, what is the format that the server accepts and comprehends?