paste.tra.pt / math-for-php · 2 years ago·
Use this code to grab a Tex-to-MathML conversion while using PHP. https://tra.pt/math for details Update CURLOPT_POSTFIELDS with your TeX math function.
<?php
$curl = curl_init();
curl_setopt_array($curl, [ CURLOPT_URL => "https://trapt.vercel.app/api/mathml", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPTPOSTFIELDS => "G{\mu\nu}=8\pi G\left(T{\mu\nu}+{\large \rho}\Lambda {\large g}_{\mu\nu} \right)", CURLOPT_HTTPHEADER => [ "Accept: application/json", "content-type: text/plain" ], ]);
$response = curl_exec($curl); $err = curl_error($curl);
curl_close($curl);
if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }