B4J Question I need help with pushbullet API

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
Use HttpUtils2. You dont need to use curl.

I've tried it, but I cant make "login".

I don't know how to "pass" my api_key to the server.

I need to "emulate" something like this:

B4X:
EXAMPLE REQUEST:

curl -u <your api key here>: https://api.pushbullet.com/api/devices
 
Upvote 0

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
Thanks for your help.

I've got it finally:

B4X:
#Region  Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 400
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
  
    Dim job As HttpJob
    job.Initialize("getdevices", Me)
    job.Username="api_key"
    job.Password=":"
    job.Download("https://api.pushbullet.com/api/devices")
End Sub

Sub JobDone (Job As HttpJob)
  Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
  If Job.Success = True Then
      Select Job.JobName
        Case "getdevices"
            'print the result to the logs
            Log(Job.GetString)
      End Select
  Else
      Log("Error: " & Job.ErrorMessage)
  End If
  Job.Release
End Sub


Now, I need help with the other part:
B4X:
EXAMPLE REQUEST:

curl https://api.pushbullet.com/api/pushes \
      -u API_KEY: \
      -d device_iden=u1qSJddxeKwOGuGW \
      -d type=note \
      -d title=Title \
      -d body=Body \
      -X POST
 
Upvote 0

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
I answer to my self:

B4X:
job.PostString("https://api.pushbullet.com/api/pushes","device_iden=1234567890xyz&type=list&title=Title&items=uno&items=dos")
 
Upvote 0
Top