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

fixing video uploads #92

Closed
wants to merge 1 commit into from
Closed

Conversation

ravimisra
Copy link

@ravimisra ravimisra commented Feb 14, 2018

Fixed the issue related to posting a video post on Tumblr.
A video post can be uploaded as follows:

$client = new Tumblr\API\Client($consumerKey, $consumerSecret);
$client->setToken($token, $tokenSecret);
$post_data = array('type' => 'video',  'caption' => 'this is a test video', 'data' => $path_of_video_file);
$createPost = $client->createPost($blog, $post_data);

@grzegorz-pierzakowski
Copy link

Merge this please

@KrishnaVishwakarma1595
Copy link

@ravimisra I'm not able to post a video even replacing the code with your updated code. Here is my code:

$client->setToken($accessToken, $accessSecret);
$res = $client->createPost('my-blog-name-goes-here', array(
'type' => 'video',
'caption' => $text,
'data' =>$path, // path is like the url of video I've uploaded
));

I tried giving the root path to the directory where the video will save, but not working.
Getting this response everytime -

Fatal error: Uncaught Tumblr\API\RequestException: [400]: Bad Request thrown in /var/www/project/lib/tumblr-api/vendor/tumblr/tumblr/lib/Tumblr/API/Client.php on line 427

@yahoocla
Copy link

Thank you for submitting this pull request, however I do not see a valid CLA on file for you. Before we can merge this request please visit https://yahoocla.herokuapp.com/ and agree to the terms. Thanks! 😄

@ravimisra
Copy link
Author

Thank you for submitting this pull request, however I do not see a valid CLA on file for you. Before we can merge this request please visit https://yahoocla.herokuapp.com/ and agree to the terms. Thanks!

Accepted terms at https://yahoocla.herokuapp.com/, please merge.

@ravimisra
Copy link
Author

@KrishnaVishwakarma1595, $path should be initialized to the filename of the video file with absolute path. e.g. /tmp/video/my_video_file_to_upload.mp4

@KrishnaVishwakarma1595
Copy link

@ravimisra Thanks for your reply. I've tried giving absolute path also but it's still giving the same error.

$client->setToken($accessToken, $accessSecret);
$res = $client->createPost('my-blog-name-goes-here', array(
'type' => 'video',
'caption' => $text,
'data' =>$path, // path is like '/var/www/project/uploads/files/video_file.mp4
));

@sndsgd
Copy link
Contributor

sndsgd commented Feb 18, 2019

@ravimisra We ended up patching this issue on the backend some time ago. I just re-tested, and was able to create a video file without issue using the following snippet (sensitive information replaced with ...):

<?php

require __DIR__ . "/vendor/autoload.php";

const CONSUMER_KEY = "...";
const CONSUMER_SECRET = "...";
const ACCESS_TOKEN = "...";
const ACCESS_TOKEN_SECRET = "...";
const BLOG = "...";

$video_file = getenv("HOME") . "/Downloads/video.mp4";

$client = new Tumblr\API\Client(CONSUMER_KEY, CONSUMER_SECRET);
$client->setToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$post_data = ["type" => "video",  "caption" => "this is a test video", "data" => $video_file];

try {
    print_r($client->createPost(BLOG, $post_data));
} catch (Exception $ex) {
    print_r($ex);
}

Please feel free to create an issue if you still run into problems posting videos.

@sndsgd sndsgd closed this Feb 18, 2019
@himanshupatel95
Copy link

Video Not Upload issue . Error status 401

require DIR . "/vendor/autoload.php";

const CONSUMER_KEY = "...";
const CONSUMER_SECRET = "...";
const ACCESS_TOKEN = "...";
const ACCESS_TOKEN_SECRET = "...";
const BLOG = "12345678";

$video_file = "../video.mp4";

$client = new Tumblr\API\Client(CONSUMER_KEY, CONSUMER_SECRET);
$client->setToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$post_data = ["type" => "video", "caption" => "this is a test video", "data" => $video_file];

try {
print_r($client->createPost(BLOG, $post_data));
} catch (Exception $ex) {
print_r($ex);
}

@sndsgd
Copy link
Contributor

sndsgd commented Nov 3, 2019

@himanshupatel95 If you're getting responses with a 401 status code, that means we could not find a user for the provided access token and access token secret.

Please go to https://api.tumblr.com/console to create a new access token and give that a shot.

@himanshupatel95
Copy link

@himanshupatel95 If you're getting responses with a 401 status code, that means we could not find a user for the provided access token and access token secret.

Please go to https://api.tumblr.com/console to create a new access token and give that a shot.

Thanks

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

Successfully merging this pull request may close these issues.

6 participants