I am a new bee to sigfox. I want to receive sensors' data from sigfox server to my webpage. I defined a callback function as in the pic below in sigfox. I want to know how to receive the JSON data in my webpage. My web page is running on a personal apache web server with a public ip.
I am using php. Like normally use a curl call to receive json from any server using its URL. Here in sigfox case, what source i.e. url I specify in curl to retrieve json data from it. OR what mechanism to use. I searched web & forum but didn't find any answer. Sigfox has a nice description about how to receiver data to an email but not for a custom url.
The body of the callback should be something like this
{
"deviceId": "{device}",
"time": {time},
"seqNumber": {seqNumber},
"data": "{data}",
"reception": [{ "id": "{station}", "RSSI": {rssi}, "SNR": {snr} }],
"duplicate": {duplicate},
"ack": {ack},
}
Other parts in your config seem ok, just write your endpoint in sigfoxdata.php to handle the data (eg. parse it).
Related
I have some data that compressed with gzip in an application from here:
app.myaddress.com/data/api/1.
The data contains several parameters in JSON format like follows:
{
"id": 1,
"data": "abcabcabcabcabc" //this is the compressed data
}
I need to check the compressed data with another 3rd party service, we can just say the address like follows: app2.myaddress.com/check_data/abcabc by API request, but it's needed a header authentication:
{
"content-type": "application/json",
"api-key": 123456
}
app2.myaddress.com will return data JSON format like follows:
{
"name": "hello",
"address": "australia"
}
What I need to do is just checking a data by accessing URL like:
app.myaddress.com/data/api/checked/1
then the controller will process the data include checking through app2.myaddress.com and return the value into app.myaddress.com
Solved by #rafitio:
You can use cURL or Guzzle to access both URL inside your function. Here is the documentation of Guzzle: http://docs.guzzlephp.org/en/stable/request-options.html
I'm porting my Android app to iOS and I'm at the chat stage.
Each message has its own date, and my server API (in PHP) has a method that fetches all messages since a date (so I can send a request with my lastMessageDate and get any new messages that are not on the device whenever needed)
My database is MySQL and the server's timezone is GMT+2. The DB saves all dates as GMT+2, and PHP sends them as string back to the client.
In Android, and in my REST client for testing, calling the following request gives the "No new messages" message, as it should:
In iOS, since the OS translates all Dates to UTC, before sending the date, I turn in into a GMT+2 string. I've been testing and debugging this date string, and it is indeed in GMT+2, as my server expects it to be.
Printing with the debugger the POST params before sending the request, shows that the time is indeed in GMT+2:
Params: ["since": "2017-03-15 21:16:04", "chat_id": "86", "username": "testuser"]
However, sending the exact same request, as in my REST client, returns chat messages that have been posted the past 2 hours, like if the iOS app is sending the UTC date instead of my GMT+2 string.
The response in the iOS emulator is the following:
Received data is:
{
"message" : "Messages in this chat:",
"messages" : [
{
"message" : "This is a message",
"chat_id" : "86",
"who" : "1",
"date" : "2017-03-15 21:16:04"
}
],
"error" : false
}
I've been trying to debug this for the past 4 hours with no luck. I don't know if it's the server's fault or iOS' fault, so if anyone can point me to the right direction, it would be very much appreciated. Thank you
Turns out I need to encode the request with Alamofire.URLEncoding.httpBody instead of Alamofire.JSONEncoding.default in order for PHP to be able to check for parameters using isset($_POST["since"]). I didn't face this problem before, in the other 40 API calls that my app encodes with Alamofire.JSONEncoding.default.
If anyone can explain when it's best to encode using URLEncoding and when JSONEncoding, let me know.
Thanks to everyone who tried to help!
I'm working on a wordpress plugin using Stupeflix api, the old one with php.
I have to migrate it to the new one. But there's a real lack of explanation on stupeflix website, and no code example on how to do.
I created an account to test it. But it seems like I need to register a domain name. Ok. But what if I need to work localy ?
Then I use the task api. The JSON's a bit skinny : How would I pass my other params like my secret key ? How to keep it secret for example, if it's clearely readable in the source code ?
Thans for your spotlights :)
PS : I cannot create a stupeflix tag on stackoverflow. Such a shame, the stupeflix author told me to use that to get supports here...
The new stupeflix API is a standard HTTP API with JSON bodies, and you can send requests to it with any librairy in any language. Every language has a decent HTTP requesting library, for example in Python I recommend python-requests or Jquery.ajax()
There's not code examples as such, but you have many JSON examples here though.
Most of the time, you only need to send POST requests to dragon.stupeflix.com/v2/create with a JSON body containing one or many tasks definitions :
{
"task_name": "video.create",
"definition": "<movie service=\"craftsman-1.0\">\n <body>\n <effect type=\"none\">\n <video filename=\"http://s3.amazonaws.com/stupeflix-assets/apiusecase/footage.mov\" speed=\"2.0\" audio=\"false\">\n <filter type=\"colormap\" preset=\"bw\"/>\n </video>\n </effect>\n </body>\n</movie>"
}
Here is the documentation. You will get a JSON response as such :
{
"status": "executing",
"result": {
"duration": 10,
"preview": "http://dragon.stupeflix.com/storage/flvstreamer/222/LY5XZIPILG6WKKIAGQAB4RLHBY/360p/preview.flv"
},
"key": "LY5XZIPILG6WKKIAGQAB4RLHBY",
"progress": 10,
"events": {
"started": "2013-11-16T06:02:55.669278+00:00",
"queued": "2013-11-16T06:02:55.667394+00:00"
}
}
I hope this will help.
I am following this tutorial to make an events calendar-it utilizes backbone and the fullcalendar jquery plugin.
Backbone is responsible for sending to the server(via ajax) event details(start date,end date,title).Here is an image of what is sent to the server.
It is taken by the network panel(headers tab) of Chrome Dev Tools. I would expect that with the following line of code I would access the title of the event:
$title=$conn->real_escape_string($_POST['title']);
But I cannot, I do not understand why this happens. backbone sends JSON to server via the POST method. What am I missing here?
PHP has a problem with parsing json data, because it expects the posted data to be in a Querystring format (key=value&key1=value1).try using this:
$content = file_get_contents("php://input");
You are sending a JSON dictionary in the request body. Use http_get_request_body in PHP to obtain the full JSON string, then json_decode it.
I'm using the (JSON) HTTP interface to communicate with SharePoint. The communication itself is done via cURL and a convinience-wrapper in PHP. Problems arise, when I want to push data to SP.
Since I'm no Microsoft / SharePoint guy, I'm missing the proper vocabulary to explain my needs. I'll therefore demonstrate using data I received from SharePoint.
GET http://example.org/mytest/_vti_bin/listdata.svc/Aufgaben(2) returns the following (truncated by me) data:
{
"d" : {
"__metadata": {
"uri": "http://example.org/mytest/_vti_bin/listdata.svc/Aufgaben(2)",
"etag": "W/\"5\"",
"type": "Microsoft.SharePoint.DataService.AufgabenItem"
},
"ID": 2,
"InhaltstypID": "0x010800821BC29B80192B4C960A688416597526",
"Inhaltstyp": "Aufgabe",
"Titel": "Neuer Titel",
"ZugewiesenAn": {
"__deferred": {
"uri": "http://example.org/mytest/_vti_bin/listdata.svc/Aufgaben(2)/ZugewiesenAn"
}
},
"ZugewiesenAnId": 29,
"F\u00e4lligkeitsdatum": "\/Date(1323993600000)\/"
}
}
"ZugewiesenAn" is a user. If I query the deferred values, I get (truncated by me, again)
{
"d" : {
"__metadata": {
"uri": "http://example.org/mytest/_vti_bin/listdata.svc/Benutzerinformationsliste(29)",
"etag": "W/\"1\"",
"type": "Microsoft.SharePoint.DataService.BenutzerinformationslisteItem"
},
"InhaltstypID": "0x010A000719C31710976A48867763D86F6586E0",
"Name": "Rehm Rodney",
"Konto": "EXT\\rodney.rehm",
"ID": 29,
"Inhaltstyp": "Person",
}
}
So I can see that the value of "ZugewiesenAn" should be "EXT\rodney.rehm" (as I need the username). Thus far, no problem.
The question is how I create a new or update an existing object with a different user for "ZugewiesenAn" (a User/Group field)?
I've tried:
Sending the username as the value of "ZugewiesenAn" or "ZugewiesenAnId" results in a Bad Request.
Querying http://example.org/_vti_bin/People.asmx (SOAP: SearchPrincipals) only yields numeric IDs for people that have actually worked with the list. If I query a username that hasn't logged into that SharePoint list before, I get ID -1.
I could not find out how to add users to the userlist via REST. You can, however, use the SOAP ResolvePrincipal request (example) - which does the job!
I am not a SharePoint guy and focus mostly on REST and OData. But think that REST OData API for SharePoint follows common rules for REST OData.
Common rules for REST and OData is to use different HTTP verbs for different operations. Read, create, update, and delete operations are mapped directly to GET, POST, PUT, and DELETE HTTP verbs.
So, you are getting your user by GET HTTP verb on URI http://example.org/mytest/_vti_bin/listdata.svc/Benutzerinformationsliste(29)
To delete this user use verb DELETE on the same URI and user id with empty HTTP message body.
To create user HTTP verb POST, same URI and json in message body. Also while creating ID shouldn't be specified (except situations when ID isn't auto-incremented in databases). Content-Type for HTTP message should be set: application/json for JSON.
The same situation with update - PUT, same URI
http://example.org/mytest/_vti_bin/listdata.svc/Benutzerinformationsliste(29)
and json in HTTP message body with content-type:application/json.
Format of json should be the same as you've received.
{
"InhaltstypID": "0x010A000719C31710976A48867763D86F6586E0",
"Name": "Rehm Rodney",
"Konto": "EXT\\rodney.rehm",
"ID": 29,
"Inhaltstyp": "Person",
}