Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

network request to back4app
Started by ashokry Jun 08 2018 03:45 AM

2 replies to this topic
network back4app
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ashokry

[GLOBAL: userInfoPane.html]
ashokry
  • Observer

  • 22 posts
  • Corona SDK

Hi, I am trying to send the following cURL using network.request but I always get error, can you pls send me how to send this request using network.request.

same command is working from MAC terminal

 

curl -X GET \

-H "X-Parse-Application-Id: b6rnGc4XpuC8NCMP8hKbz4oDG3QuZZz06w1FeDXi" \

-H "X-Parse-REST-API-Key: UDGuerOe0TntbXB0J18U5HxQrtUucT1npluvfJmw" \

-H "X-Parse-Revocable-Session: 1" \

-G --data-urlencode 'username=ashraf' \

--data-urlencode 'password=aa' \

https://parseapi.back4app.com/login

 

Thank you



[TOPIC: post.html]
#2

Develephant

[GLOBAL: userInfoPane.html]
Develephant
  • Corona Geek

  • 1,427 posts
  • Corona SDK

Hi,

 

You should be able to do it like so:

local url = require("socket.url")

local function onRequest(event)
  if ( event.isError ) then
    print( "Network error: ", event.response )
  else
    print ( "RESPONSE: " .. event.response )
  end
end

local params = {
  headers = {
    ["X-Parse-Application-Id"] = "b6rnGc4XpuC8NCMP8hKbz4oDG3QuZZz06w1FeDXi",
    ["X-Parse-REST-API-Key"] = "UDGuerOe0TntbXB0J18U5HxQrtUucT1npluvfJmw",
    ["X-Parse-Revocable-Session"] = "1"
  }
}

local username = url.escape("ashraf")
local password = url.escape("aa")

local query = string.format("username=%s&password=%s", username, password)

local uri_path = "https://parseapi.back4app.com/login?"..query

network.request( uri_path, "GET", onRequest, params )

Hope that helps.

 

-dev


  • roaminggamer likes this

[TOPIC: post.html]
#3

ashokry

[GLOBAL: userInfoPane.html]
ashokry
  • Observer

  • 22 posts
  • Corona SDK

Hi,

 

Thank you for your support.

For years I used your great mod_parse, and parse plugin, but currently it is not working with back4appm this is why I am trying to use my old code and change the mod_parse calling to network REST API calling.

What about other functions, like class queue with complicated where? os there any samples or reference on how to translate CURL to coronasdk.

 

Thank you so much for your support.




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: network, back4app