Hello,
I'm writing a plugin
This plugin has a task function
I want to use a post or get request through a third-party service,
Then want to ask how to adjust the URL to return the data type json?
if (isset($_POST)) { echo 'json'; }
Thank you
Piwigo 12.0.0beta2
WINNT
PHP: 7.3.4 [2021-08-27 17:14:57]
MySQL: 5.7.26 [2021-08-27 17:14:57]
GD bundled (2.1.0 compatible)
Offline
Here I'm just going to imitate something like this
Write the template file to $template
if (isset($_POST)) { echo 'json'; # or array_push($page['infos'], 'seed successful'); } $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/upload.tpl'); $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
But I don't think that's what I want
Offline
Can you give me some hints? I really want to know
When I asked for the login interface, I got the correct JSON format
But when I go through the url of the plugin, I get the HTML page
Can you give me some hints on the internal functions
Or some demo on Github
$url = 'http://127.0.0.1/ws.php?format=json' $form_data = { 'method': 'pwg.session.login', 'username': 'name', 'password': 'pass', } $results = "requests url" results: {"stat":"ok","result":true}
But
# plugin-ImageAcquisition-upload # This is my custom plugin path url = 'http://192.168.31.53/admin.php?page=plugin-ImageAcquisition-upload' $form_data = { 'submit': 'submit', } $results = "requests url" results: <!DOCTYPE html>
I'm not particularly familiar with this, so if anyone can guide me, I'd appreciate it
Offline
I read several times your messages and I'm not sure to understand what you want nor what you try to do. Can you explain it another time ?
I take my chance in any case.
WIth your plugin, you can add your own methods to the Piwigo API using ws_add_methods event handler. Of course theses methods can return json if you want.
Offline