1

Tumblrに接続しています(twitterとほぼ同じ手順です)。検証ページまでたどり着き、アプリを検証してから、前のページに戻ります。正しいものはすべてクエリ文字列にありますが、API ドキュメントで 400 エラーが少し発生し、これは「無効な入力データ」。

これが私のコードです:

        require("tumblr/tumblroauth/tumblroauth.php");
        // Enter your Consumer / Secret Key:
        $consumer   = $conf['Tumblr']['consumer'];
        $secret     = $conf['Tumblr']['secret'];
        /* Start session and load lib */
        if(!isset($_REQUEST['oauth_token']))
        {
            // Start the Session
            session_start();
            $connection = new TumblrOAuth($conf['Tumblr']['consumer'], $conf['Tumblr']['secret']);
                    // this url is correct
            $url = "http://" . $_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI'];
            $temporary_credentials = $connection->getRequestToken($url);
            $redirect_url = $connection->getAuthorizeURL($temporary_credentials, FALSE);

            echo "going to".$redirect_url; // looks good
                    //have to use this as headers have started
            echo '<script>window.location.href="'.$redirect_url.'";</script>';
        }

        /* If the oauth_token is old redirect to the connect page. */
        if (isset($_REQUEST['oauth_token']) && $_SESSION['oauth_token'] !== $_REQUEST['oauth_token']) {
          $_SESSION['oauth_status'] = 'oldtoken';
          session_destroy();
        }
        if(isset($_REQUEST['oauth_token']))
        {/* Create TumblroAuth object with app key/secret and token key/secret from default phase */
            $connection = new TumblrOAuth($consumer, $secret, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);

            /* Request access tokens from tumblr */
            $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);

            /* Save the access tokens. Normally these would be saved in a database for future use. */
            $_SESSION['access_token'] = $access_token;

            /* Remove no longer needed request tokens */
            unset($_SESSION['oauth_token']);
            unset($_SESSION['oauth_token_secret']);

            /* If HTTP response is 200 continue otherwise send to connect page to retry */
            if (200 == $connection->http_code) {
              /* The user has been verified and the access tokens can be saved for future use */
              $_SESSION['status'] = 'verified';
              echo 'connection made heres the code:<br/>'.$connection->http_code;
            } else {
              /* Save HTTP status for error dialog on connnect page.*/


                     // THIS IS ALWAYS BEING OUTPUT AT THE END
             echo "oh no something is wrong code:<br/>".$connection->http_code;
            }
        }

誰かがこれを機能させるために地球上のすべてを試したような気がする.. psを使用して見てください: https://github.com/jacobbudin/tumblroauth

4

1 に答える 1

0

あなたの問題はここにあると思います

    $redirect_url = $connection->getAuthorizeURL($temporary_credentials, FALSE);

試す

    $redirect_url = $connection->getAuthorizeURL($temporary_credentials);

それでも問題が解決しない場合はお知らせください

于 2012-06-21T19:52:30.063 に答える