Coder Social home page Coder Social logo

Comments (7)

dcai avatar dcai commented on July 16, 2024

Proposed request format, the http body will be the $eventdata in json format.

cc @jleyva


POST http://push.moodle.net/notification/
X-AN-APP-NAME: moodlemobile
X-AN-APP-KEY: 4EF234523AD
Content-Type: application/json

{
  "alert": "blogger#post",
  "device": "",
  "token" : "device token/regid for gcm/channel url for windows",
  "sound": "",
  "badge": "",
  "userfrom": "",
  "userto": "",
  "subject": "message subject",
  "fullmessage": "",
  "timecreated": "",
}

from airnotifier.

jleyva avatar jleyva commented on July 16, 2024

I think that we should distinguish between the "full message object" and the Airnotifier required parameters by AIRNOTIFIER (APPNAME, APPKEY, TOKEN, etc...)

So, why don't use HEADERS for platform and token and the body for the rest of the elements?
Notice that the token size (length) can be huge, so I'm not sure if HTTP headers will be valid

Another option is tu use prefixes for the Airnotifier required parameters like:

{
"alert": "blogger#post",
"an-device": "",
"an-token" : "device token/regid for gcm/channel url for windows",
"sound": "",
"badge": "",
"userfrom": "",
"userto": "",
"subject": "message subject",
"fullmessage": "",
"timecreated": "",
}

from airnotifier.

jleyva avatar jleyva commented on July 16, 2024

Another question, do you think that the current curl class (you made for Moodle) can support this type of requests?
I've been looking the code and I see methods por POST/GET/PUT and a generic method called request

from airnotifier.

dcai avatar dcai commented on July 16, 2024

Hi @jleyva

It might not be the best option to use customized headers for mandatory parameters, "X-" headers are being deprecated: http://tools.ietf.org/html/rfc6648

It looks a little messy to use prefixes in JSON, probably we could keep required parameters on top level, and optional parameters in a nested property, it looks like:

POST http://push.moodle.net/api/v2/push/
X-AN-APP-NAME: moodlemobile
X-AN-APP-KEY: 4EF234523AD
Content-Type: application/json

{
  "alert": "Notification from client",
  "device": "wns",
  "token" : "for wns, this is a channel url",
  "sound": "",
  "badge": "",
  "wns": {
    "type": "toast",
    "image": "...",
    "template: "ToastImageAndText04"
  }
  "extra": {
    "processor": "moodle",
    "data": {
      "userfrom": "",
      "userto": "",
      "subject": "message subject",
      "fullmessage": "",
      "timecreated": "",
    }
  }
}

from airnotifier.

dcai avatar dcai commented on July 16, 2024

And if required parameters are missing "400 Bad Request" should be responded, 202 if successfully (200 at the moment, but 202 Accepted is more appropriated for triggering an event)

from airnotifier.

dcai avatar dcai commented on July 16, 2024

Another question, do you think that the current curl class (you made for Moodle) can support this type of requests?
I've been looking the code and I see methods por POST/GET/PUT and a generic method called request

Yes, you can do $curl->post($url, json_enable($eventdata));, when the second parameter isn't array, curl library will use it as raw post body.

from airnotifier.

jleyva avatar jleyva commented on July 16, 2024

+1 extra properties nested

Thanks for the clarification about the curl library

from airnotifier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.