Issue using wp_remote_post to upload on Flickr: “POST size too large!”
-
Hi folks,
I’m actually building my own Flickr uploader, directly attached to my website.
A few days ago, I started to dig into Flickr API…
It have been a challenge because the documentation is quite poor and not updated for years (ie. the complete part about uploading is still based on the old authentication method and not oauth…)Anyway, I’ve been able using Paw app (from https://paw.cloud guys) to make a fully working POST to Flickr using oauth.
The image is uploaded, title, description and tags are set, in short, all upload attributes from the Flickr API are working.Since I’ve this working, I started to implement this in my PHP.
I’m using the generated code from Paw app and before starting to replace all hardcoded values with variables, I would like to make sure it’s working “as this” on PHP, since it works in PAW.
Sadly, that’s not the case, and when the request is made, I’ve receiving the following response: “POST size too large! Try something smaller, mmkay?”Here’s the PHP generated code (for WordPress)
$photoData = file_get_contents('./SocialMediaTest-320x213.jpg');
// {@see https://codex.www.ads-software.com/HTTP_API}
$response = wp_remote_post( 'https://up.flickr.com/services/upload/?content_type&description&is_public&safety_level&tags&title', array(
'headers' => array(
'Cookie' => 'xb=216022; flrbp=1488012692-ca7d52c458e45dXXXXXXXXX5a46f6d46e0; flrbs=1488012692-93e7ce0fd7312c5XXXXXXXXXXX15d69274c54d; flrbgrp=1488012692-44b3d5b961cXXXXXXXXXXX7667a3fb4544a; flrbgdrp=1488012692-3b54eXXXXXXXXXXXae99e73; flrbgmrp=1488012692-36becfd2a6f5XXXXXXXXXXX678ca0d52d; flrbcr=1488012692-cb55143f26b9dXXXXXXXXXXX27cf7ed9; flrbrst=1488012692-f11afab597XXXXXXXXXXX8dbc9791c0e; flrtags=1488012692-2eda10d7b1dXXXXXXXXXXXfb5e513ca; localization=fr-fr%3Bfr%3Bfr',
'Authorization' => 'OAuth oauth_consumer_key="XXXXXXXXX", oauth_nonce="XXXXXXXX", oauth_signature="XXXXXXXXX", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1488063052", oauth_token="XXXXXXXXXXX", oauth_version="1.0"',
'Content-Type' => 'multipart/form-data; charset=utf-8; boundary=__X_PAW_BOUNDARY__',
),
'body' => array(
'content_type' => '1',
'is_public' => '0',
'title' => 'Social Media Test',
'description' => 'This is a test of an automated post for social media',
'photo' => $photoData,
'tags' => 'tag1 tag2 tag3',
'safety_level' => '3',
),
) );if ( ! is_wp_error( $response ) ) {
// The request went through successfully, check the response code against
// what we're expecting
if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
// Do something with the response
// $body = wp_remote_retrieve_body( $response );
// $headers = wp_remote_retrieve_headers( $response );
} else {
// The response code was not what we were expecting, record the message
$error_message = wp_remote_retrieve_response_message( $response );
}
} else {
// There was an error making the request
$error_message = $response->get_error_message();
}
If you have any idea of what could go wrong, I would greatly appreciate your input!
Thanks in advance.
- The topic ‘Issue using wp_remote_post to upload on Flickr: “POST size too large!”’ is closed to new replies.