Dim Const PB As String = "https://api.pushbullet.com/v2/"
' Get information about the current user.
Dim Const PBme As String = PB&"users/me"
[..]
Dim job As HttpJob
job.Initialize("ME",Me)
job.Download(PBme)
job.GetRequest.SetHeader("Authorization", "Bearer "&secret)
Sub JobDone (job As HttpJob)
LogColor("JobDone ("&job.JobName&")",Colors.Blue)
If job.Success = True Then
Select job.JobName
Case "ME"
lv.Clear
Log(job.GetString)
Dim parser As JSONParser
parser.Initialize(job.GetString)
Dim root As Map = parser.NextObject
Dim iden As String = root.Get("iden")
lv.AddTwoLines2(iden,"iden",root)
Dim email As String = root.Get("email")
lv.AddTwoLines2(email,"eMail",root)
Dim name As String = root.Get("name")
lv.AddTwoLines2(name,"Name",root)
Dim created As Double = root.Get("created")
lv.AddTwoLines2(created,"Created",root)
Dim google_userinfo As Map = root.Get("google_userinfo")
Dim name As String = google_userinfo.Get("name")
Dim email_normalized As String = root.Get("email_normalized")
Dim preferences As Map = root.Get("preferences")
Dim onboarding As Map = preferences.Get("onboarding")
Dim extension As String = onboarding.Get("extension")
Dim app As String = onboarding.Get("app")
lv.AddTwoLines2(app,"App",root)
Dim friends As String = onboarding.Get("friends")
lv.AddTwoLines2(friends,"Friends",root)
Dim mac As String = onboarding.Get("mac")
lv.AddTwoLines2(mac,"Mac",root)
Dim modified As Double = root.Get("modified")
lv.AddTwoLines2(modified,"Modified",root)
Dim image_url As String = root.Get("image_url")
[...]
it is really great...sounds good
Dim PBService AsString = "https://api.pushbullet.com/v2/pushes/"
Dim TargetDevice as string = "udm0Tdjz5A7bL4NM" ' sets the target devices's device_iden here; a list is provided by v2/devices API
Dim job AsHttpJob
job.Initialize("ME",Me)
job.Download(PBService&TargetDevice)
'set header 'Content-Type: application/json
'set data-binary '{"type": "note", "title": "Note Title", "body": "Note Body"}'
job.GetRequest.SetHeader(...)
You are missing the target too. THAT´s my problem. Where to "put" the target?device you should call
"https://api.pushbullet.com/v2/pushes?device_iden=MyDeviceIden"
I dont know whether i should make a class or lib...actually it is only just simple b4a code using httputils...Are you coding a class/library to make use of PB? Do you plan to use it for any specific project (like an "help me" message send to all the registered/channeled devices)?
thanx for you answer... I´ll try to use this in the post-json-payload (not using get-parameter as you suggested)Its a param so put
Sub Button1_Click
Dim json As JSONGenerator
'--data-binary '{"type": "note", "title": "Note Title", "body": "Note Body"}'
json.Initialize(CreateMap("type": "note", "title": subject.Text, "body": body.Text))
Dim job As HttpJob
job.Initialize("PUSH",Me)
job.Poststring(Main.PBpushes,json.ToString)
job.GetRequest.SetHeader("Authorization", "Bearer "&Main.secret)
job.GetRequest.SetHeader("Content-Type", "application/json")
End Sub
When it works for you then the use of the device_iden is correct. Great! This will help mewell, at least I hope so, since I have only one device
But your code will work only for the LAST device listed in the result of devices
I did not see any pro account. I also did not get any mail offering me a pro account or so.BTW, do you know if all this PB world is free?
If you dont set a target then you will get pushed to all your devices.When it works for you then the use of the device_iden is correct.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?