Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// construct upload url
$upload_url = 'https://tinypay.me/mashape';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_URL, $upload_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
$post = array(
'file' => '@'.$medium_local_path,
'_token' => $mashape_token,
'_method' => 'uploadImage',
'access_token' => $_SESSION['tiny_access_token'],
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
if(!empty($response)){
$response = json_decode($response);
if(isset($response->result->thumbnail)){
$image_token = $response->result->token;
echo ' done! see <a href="'.$response->result->thumbnail.'" target="_blank">thumbnail</a><p>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.