All I can say is that it works as a query link in the browser. I open a new tab, I enter
https://hub.debenny.de/api/z/1.0/item/update?body=foo
Then I get the following JSON printed in the new broser tab:
{
"success": true,
"item_id": "12260",
"item": {
"id": "12260",
"mid": "2774cf2e4e9e0a082370ea06a1c18d828adb185054eb2de279eca49727398482@hub.debenny.de",
"aid": "1",
"uid": "3",
"parent": "12260",
"parent_mid": "2774cf2e4e9e0a082370ea06a1c18d828adb185054eb2de279eca49727398482@hub.debenny.de",
"thr_parent": "2774cf2e4e9e0a082370ea06a1c18d828adb185054eb2de279eca49727398482@hub.debenny.de",
"created": "2018-01-18 18:56:24",
"edited": "2018-01-18 18:56:24",
"expires": "0001-01-01 00:00:00",
"commented": "2018-01-18 18:56:24",
"received": "2018-01-18 18:56:25",
"changed": "2018-01-18 18:56:25",
"comments_closed": "0001-01-01 00:00:00",
"owner_xchan": "7GUJg9yFkKc8bU0XkfvNz34g6lrIvQi2wTPIxwQ1YUc2fO6vM482NmhqUqY7Z47FpvNHg7psHK80m1zTzRkt5Q",
"author_xchan": "7GUJg9yFkKc8bU0XkfvNz34g6lrIvQi2wTPIxwQ1YUc2fO6vM482NmhqUqY7Z47FpvNHg7psHK80m1zTzRkt5Q",
"source_xchan": "",
"mimetype": "text/bbcode",
"title": "",
"body": "foo",
"html": "",
"app": "",
"lang": "",
"revision": "0",
"verb": "http://activitystrea.ms/schema/1.0/post",
"obj_type": "http://activitystrea.ms/schema/1.0/note",
"obj": "",
"tgt_type": "",
"target": "",
"layout_mid": "",
"postopts": "",
"route": "",
"llink": "https://hub.debenny.de/display/2774cf2e4e9e0a082370ea06a1c18d828adb185054eb2de279eca49727398482@hub.debenny.de",
"plink": "https://hub.debenny.de/channel/tce/?f=&mid=2774cf2e4e9e0a082370ea06a1c18d828adb185054eb2de279eca49727398482@hub.debenny.de",
"resource_id": "",
"resource_type": "",
"attach": "",
"sig": "j9Ley1KkHOLXFHldbsY204GPFTXCNelQ5nTKSGHwLlB1KIHYjXc3s5Um6mPYkbGMWWjakX3MyX7OIUkEnWPx7cnhqk4hOBTihPNzNFGqqHfITSfhacs-K8cfLNiiT91imDTmjidlktw5Sozk9SShooT7aiQ6gn8DxueR8VF0v2B6eWhm6KkzDn2bALYkGKMf-mQepR3xSrNMSnhLEefgUfew8SmNJtuo2DylkjQgFoulV1QOTajVhPkBq03HaqzaYzbkUfJtTd11wphffzYEXYXxYGPBGn-0cDRcXpZp4pRxQwe1EyF0SCBhVtk99OYi9sRntXXOIJ-8im5DeVNO1EXhOQVtU_-xeui4YBsOryeg-KmrRNSVyPnjUR-xB1mN3j6-YJ7cTOMEVn2npHbKD78NDbEZVaNvny6xf_a9LW48T9bg08unp_kKAl4T0npn26rRhiWr8D3Hck5zbtibnqDGNgIBQQVz0a0CPCiyfsUTFbaqfVmYgoQNXNSzycxOnHRub6jSNzaP-DwT84xQALxtsOLr5D65ufPyzmB5V5sTk8_C7HcYDplftbmBxgTN1nxOzp1ebVCSolr--9JhNudm7hORXSYlj5kXu_CVNZVgGeR4kX58Ja5uNK87jPcHsvOedm97XdcYGEkVvXgRyGn5y6IZnXETB2pNlxWPv4w",
"location": "",
"coord": "",
"public_policy": "",
"comment_policy": "public",
"allow_cid": "",
"allow_gid": "",
"deny_cid": "",
"deny_gid": "",
"item_restrict": "0",
"item_flags": "0",
"item_private": "0",
"item_origin": "1",
"item_unseen": "0",
"item_starred": "0",
"item_uplink": "0",
"item_consensus": "0",
"item_wall": "1",
"item_thread_top": "1",
"item_notshown": "0",
"item_nsfw": "0",
"item_relay": "0",
"item_mentionsme": "0",
"item_nocomment": "0",
"item_obscured": "0",
"item_verified": "1",
"item_retained": "0",
"item_rss": "0",
"item_deleted": "0",
"item_type": "0",
"item_hidden": "0",
"item_unpublished": "0",
"item_delayed": "0",
"item_pending_remove": "0",
"item_blocked": "0"
}
}
And if I open my stream in Hubzilla, I get the message like so:
Okay,so I shall stick with POST…
I got a message from the main developer of Hubzilla saying I’d need to add application/x-www-form-urlencode, so I did:
$.ajax({
url: 'https://'+hub+'/api/z/1.0/item/update',
type: 'POST',
crossDomain: true,
data: quote,
headers: {
'Authorization': `${username}:${password}`,
'Content-Type':'application/x-www-form-urlencode'
}
})
.then(console.log)
.catch(console.error)
Still get an error.
window.open is not an API to use for AJAX. If your user’s browser is set up to block pop-ups, your app will break.
This is something I didn’t consider. Thank you. As I intended to get all interaction in an external window or kind of overlay, I thought this would be ideal,especially since I found out the link to an input field for network posts. I could set the text of the textfield and let the user edit before it is sent to the network…
But what you write is a deal breaker. I think I might look into Bootstrip Modals or something similar instead of relying on pop-ups…
I never heard of fetch or Axios. Thank you for the links.