MOFH-API-Docs icon indicating copy to clipboard operation
MOFH-API-Docs copied to clipboard

Tickets cURL code is illegal

Open greenreader9 opened this issue 7 months ago • 1 comments

Affected pages:

  • https://github.com/Wallvon/MOFH-API-Docs/blob/main/pages/XML/tickets/create.mdx
  • https://github.com/Wallvon/MOFH-API-Docs/blob/main/pages/XML/tickets/user-reply.mdx
  • https://github.com/Wallvon/MOFH-API-Docs/blob/main/pages/JSON/tickets/create.mdx
  • https://github.com/Wallvon/MOFH-API-Docs/blob/main/pages/JSON/tickets/user-reply.mdx

Issue: These pages include a sample cURL call such as (formatted):

curl -X POST 
    -u username:password 
    -d "api_user=username&api_key=password&domain_name=subdomain.example.com&ticket_id=000000" 
    -F ticket_id=000000 
    -F clientusername=hname_12345678 
    -F comments=Test 
    -F ipaddress=1.1.1.1
    "https://panel.myownfreehost.net/xml-api/supportreplyticket.php"

Per documentation, -d and -F are mutually excusive, only one can be used (docs, docs)

To resolve: Untested, but I think moving all them to -d is the correct way to go, that would also help these pages remain consistent with the rest.

The following PHP code works if you want to model off it:

$post_data = array(
	'comments' => $comm6,
	'ticket_id' => $comm7,
        'clientusername' => $comm5,
	'domain_name' => $comm4,
	'ipaddress' => $comm3,
	'api_user' => $comm2,
	'api_key' => $comm1
);

$curl = curl_init();
curl_setopt_array($curl, array(
	 CURLOPT_URL => 'https://panel.myownfreehost.net/xml-api/supportreplyticket',
	 CURLOPT_RETURNTRANSFER => true,
	 CURLOPT_MAXREDIRS => 10,
	 CURLOPT_TIMEOUT => 0,
	 CURLOPT_POST => 1,
	 CURLOPT_FOLLOWLOCATION => true,
	 CURLOPT_CUSTOMREQUEST => 'POST',
	 CURLINFO_HEADER_OUT => true,
	 CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
	 CURLOPT_POSTFIELDS => $post_data,
));

$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);

greenreader9 avatar Mar 15 '25 01:03 greenreader9