Skip to content

Instantly share code, notes, and snippets.

@melvinmt
Created March 1, 2011 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melvinmt/849461 to your computer and use it in GitHub Desktop.
Save melvinmt/849461 to your computer and use it in GitHub Desktop.
<?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