Created
July 10, 2015 19:44
-
-
Save delalis/5c7ecc2aaa024927b360 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$square_url = 'https://connect.squareup.com/v1/me/items/27/image'; | |
$cfile = new CURLFile('sites/default/files/styles/artists_page/public/artists/grant.png', 'image/png', 'image_data'); | |
$image_data = array('image_data' => $cfile); | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, array( | |
'Authorization: Bearer ' . $access_token, | |
'Content-Type: multipart/form-data; boundary=BOUNDARY', | |
'Accept: application/json' | |
)); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $image_data); | |
curl_setopt($curl, CURLOPT_URL, $square_url); | |
curl_setopt($curl, CURLOPT_POST, TRUE); | |
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, TRUE); | |
curl_setopt($curl, CURLOPT_BINARYTRANSFER, TRUE); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); | |
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); | |
curl_setopt($curl, CURLINFO_HEADER_OUT, TRUE); | |
curl_setopt($curl, CURLOPT_VERBOSE, TRUE); | |
$json = curl_exec($curl); | |
echo("curl result:"); | |
if (!$json) { | |
die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl)); | |
} | |
else { | |
echo $json; | |
} | |
curl_close($curl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment