Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with -F= #32

Open
phpandrew opened this issue Sep 11, 2020 · 0 comments
Open

Issue with -F= #32

phpandrew opened this issue Sep 11, 2020 · 0 comments

Comments

@phpandrew
Copy link

phpandrew commented Sep 11, 2020

curl -X POST "https://api.squarespace.com/1.0/commerce/products/123/images" -i -H "Authorization: Bearer YOUR_API_KEY_OR_OAUTH_TOKEN" -H "User-Agent: YOUR_CUSTOM_APP_DESCRIPTION" -F file=@steak.png

Results in:

// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.squarespace.com/1.0/commerce/products/123/images');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'file' => '@' .realpath('steak.png'));

$headers = array();
$headers[] = 'Authorization: Bearer YOUR_API_KEY_OR_OAUTH_TOKEN';
$headers[] = 'User-Agent: YOUR_CUSTOM_APP_DESCRIPTION';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);

It should be:
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => '@' .realpath('steak.png')));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant