Skip to content

MathPix-API: PHP sample is missing #3

@q2apro

Description

@q2apro

Could you add an example for PHP, I am stuck with this custom code:

$uploadedFile = file_get_contents('ztest.jpg');

$ch = curl_init();

curl_setopt_array($ch, array(
	CURLOPT_RETURNTRANSFER => true, // receive server response
	CURLOPT_URL => "https://api.mathpix.com/v3/latex",
	CURLOPT_POST => 1,
	CURLOPT_HTTPHEADER => array('Content-Type:application/json'),
	CURLOPT_POSTFIELDS => array(
		"app_id" => "trial",
		"app_key" => "34f1a4cea0eaca8540c95908b4dc84ab",
		"src" => "data:image/jpeg;base64,".base64_encode($uploadedFile), // data	
	)
));

$result = curl_exec($ch);

curl_close($ch);

// further processing
if($result == "OK") 
{
	// **** how to access the latex results?!
	var_dump('Okay');
} 
else 
{
	var_dump($result);
}

I guess the data should not be sent by "src" but differently using CURL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions