Code Monkey home page Code Monkey logo

Comments (15)

codingjester avatar codingjester commented on July 29, 2024

Does https://api.tumblr.com/console not give you what you are looking for here? You should see implementations in your language of choice and give you back some tokens.

from tumblr.php.

austinkregel avatar austinkregel commented on July 29, 2024

When I use the console, it only gives me tokens to access my own blog. I want to be able to authenticate a user and show their own dash. That way anyone can view their own blog feed.

from tumblr.php.

seejohnrun avatar seejohnrun commented on July 29, 2024

@austinkregel https://github.com/tumblr/tumblr.php/wiki/Authentication ! :)
Hope that helps!

from tumblr.php.

austinkregel avatar austinkregel commented on July 29, 2024

It doesn't help. It far from helps. A link to my sample page is below... It takes FOREVER to make the requests, and for me that is unacceptable. I'm sure that there is another way to make requests without them taking as long as they do.
I copied and pasted the Authentication page, and replaced the key and secret that I needed to.

Link: http://embb.pw/unus/__core/tumblr-manager.php

from tumblr.php.

codingjester avatar codingjester commented on July 29, 2024

@austinkregel have you done any kind of benchmarking to see what part of the process is actually holding up here? A slow loading page can be any number of various things.

We need a little bit more if we're going to help you on why it's taking so long to do anything. :)

Thanks!

from tumblr.php.

austinkregel avatar austinkregel commented on July 29, 2024

I will download, install, setup, and let you know the results of a benchmark. I have honestly never done a benchmark because I didn't know you could do it for php.

from tumblr.php.

austinkregel avatar austinkregel commented on July 29, 2024

@codingjester Okay so I have a nice debug tool here, according to my results.
Retrieving the access token, is taking quite a while. ( I used the time(); function in php)
Log time:1410289909. current time: 1410289970
After all that happens I get to the part at the end of the script where I try to create the new Tumblr\API\Client and it errors out saying I don't have access.
Fatal error: Uncaught Tumblr\API\RequestException: [401]: Not Authorized thrown in /tumblr-php/lib/Tumblr/API/Client.php on line 427

from tumblr.php.

codingjester avatar codingjester commented on July 29, 2024

@austinkregel can you post a gist of the code you're currently working on without your consumer key and secret. That way I can kinda grok exactly what you're doing right now with the script.

Thanks :)

from tumblr.php.

austinkregel avatar austinkregel commented on July 29, 2024

@codingjester you can see the gist here https://gist.github.com/austinkregel/4c7564a9dc1d72754934

from tumblr.php.

austinkregel avatar austinkregel commented on July 29, 2024

@codingjester I don't know if you will be able to see the log in the developer console if you try the demo. Here is the one I keep getting.
We have set the base url, the key and secret.

  Now we make the request log.js:137
  Log time:1410291199. current time: 1410291199 
  request made! 
  Log time:1410291199. current time: 1410291200 
  parsed the request! 
  Log time:1410291199. current time: 1410291200 
  now we authorize! 
  Token authorized!! 
  Log time:1410291199. current time: 1410291200 
  Requesting access token 
  Log time:1410291199. current time: 1410291260 
  Requesting access token. 
  Log time:1410291199. current time: 1410291260 
  Access token set. 
  Log time:1410291199. current time: 1410291260 
  getting user info. 

from tumblr.php.

austinkregel avatar austinkregel commented on July 29, 2024

@codingjester @seejohnrun Is there anyway I can do authentication without using it as a CLI script?

from tumblr.php.

khurshid-alam avatar khurshid-alam commented on July 29, 2024

@austinkregel
I commented on the gist but also posting here. Try this code & run from your website in browser.

session_start(); 

require_once('vendor/autoload.php');

$consumerKey = 'XXX';
$consumerSecret = 'YYY';
$client = new Tumblr\API\Client($consumerKey, $consumerSecret);
$requestHandler = $client->getRequestHandler();
$requestHandler->setBaseUrl('https://www.tumblr.com/');

// If we are visiting the first time
if (!$_GET['oauth_verifier']) {

    // grab the oauth token
    $resp = $requestHandler->request('POST', 'oauth/request_token', array());
    $out = $result = $resp->body;
    $data = array();
    parse_str($out, $data);

    // tell the user where to go
    echo '<a href="https://www.tumblr.com/oauth/authorize?oauth_token=' . $data['oauth_token'].'"> GO </a>';
    $_SESSION['t']=$data['oauth_token'];
    $_SESSION['s']=$data['oauth_token_secret'];

} else {

    $verifier = $_GET['oauth_verifier'];

    // use the stored tokens
    $client->setToken($_SESSION['t'], $_SESSION['s']);

    // to grab the access tokens
    $resp = $requestHandler->request('POST', 'oauth/access_token', array('oauth_verifier' => $verifier));
    $out = $result = $resp->body;
    $data = array();
    parse_str($out, $data);

    // and print out our new keys we got back
    $token = $data['oauth_token'];
    $secret = $data['oauth_token_secret'];
    echo "token: " . $token . "<br/>secret: " . $secret;

    // and prove we're in the money
    $client = new Tumblr\API\Client($consumerKey, $consumerSecret, $token, $secret);
    $info = $client->getUserInfo();
    echo "<br/><br/>congrats " . $info->user->name . "!";

}

from tumblr.php.

austinkregel avatar austinkregel commented on July 29, 2024

YES! Thank you! That works better than I could hope. It's super quick to. @khurshid-alam you're awesome.

from tumblr.php.

khurshid-alam avatar khurshid-alam commented on July 29, 2024

Thanks..glad I could help.

from tumblr.php.

codingjester avatar codingjester commented on July 29, 2024

Thanks @khurshid-alam I was just about to code up an example myself :D

from tumblr.php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.