我正在与亚伯拉罕的<a id="edit" href="javascript:openDocument('asd.docx');">
合作,在我的应用程序中实现Twitter OAuth。在运行我的应用程序时,这是我遇到的错误:
twitteroauth
redirect.php(直到第158行):
Fatal error: Uncaught exception 'Abraham\TwitterOAuth\TwitterOAuthException' with message '<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Language" content="en-us"> <meta name="robots" content="noindex, nofollow"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Twitter / ?</title> <link href="https://abs.twimg.com/favicons/favicon.ico" rel="shortcut icon" type="image/x-icon"> <link rel="stylesheet" href="https://abs.twimg.com/errors/fullscreen_errors-91ecc652e4fafac52ce8a1a8a181ad24.css"> </head> <body> <div class="topbar js-topbar"> <div class="global-nav" data-section-term="top_nav"> <div class="global-nav-inner"> <div class="container"> <ul class="nav js-global-actions"> <li class="home"> <a class="nav-logo-link" href="https://twitter.com"><img class=" in /opt/lampp/htdocs/twitta/redirect.php on line 158
上述代码中的<?php
namespace Abraham\TwitterOAuth;
session_start();
//require('twitteroauth/src/TwitterOAuth.php');
/*
include 'twitteroauth/src/TwitterOAuth.php';
use Abraham\TwitterOAuth\TwitterOAuth;
*/
/**
* The most popular PHP library for use with the Twitter OAuth REST API.
*
* @license MIT
*/
use Abraham\TwitterOAuth\Util\JsonDecoder;
require "twitteroauth/autoload.php";
//use Abraham\TwitterOAuth\TwitterOAuth as Config;
use Abraham\TwitterOAuth\Response as Response;
use Abraham\TwitterOAuth\HmacSha1 as HmacSha1;
use Abraham\TwitterOAuth\Consumer as Consumer;
use Abraham\TwitterOAuth\Request as Request;
use Abraham\TwitterOAuth\Util as Util;
use Abraham\TwitterOAuth\TwitterOAuthException as TwitterOAuthException;
/**
* TwitterOAuth class for interacting with the Twitter API.
*
* @author Abraham Williams <abraham@abrah.am>
*/
class TwitterOAuth extends Config
{
const API_VERSION = '1.1';
const API_HOST = 'https://api.twitter.com';
const UPLOAD_HOST = 'https://upload.twitter.com';
/** @var Response details about the result of the last request */
private $response;
/** @var string|null Application bearer token */
private $bearer;
/** @var Consumer Twitter application details */
private $consumer;
/** @var Token|null User access token details */
private $token;
/** @var HmacSha1 OAuth 1 signature type used by Twitter */
private $signatureMethod;
/**
* Constructor
*
* @param string $consumerKey The Application Consumer Key
* @param string $consumerSecret The Application Consumer Secret
* @param string|null $oauthToken The Client Token (optional)
* @param string|null $oauthTokenSecret The Client Token Secret (optional)
*/
public function __construct($consumerKey, $consumerSecret, $oauthToken = null, $oauthTokenSecret = null)
{
$this->resetLastResponse();
$this->signatureMethod = new HmacSha1();
$this->consumer = new Consumer($consumerKey, $consumerSecret);
if (!empty($oauthToken) && !empty($oauthTokenSecret)) {
$this->token = new Token($oauthToken, $oauthTokenSecret);
}
if (empty($oauthToken) && !empty($oauthTokenSecret)) {
$this->bearer = $oauthTokenSecret;
}
}
/**
* @param string $oauthToken
* @param string $oauthTokenSecret
*/
public function setOauthToken($oauthToken, $oauthTokenSecret)
{
$this->token = new Token($oauthToken, $oauthTokenSecret);
}
/**
* @return string|null
*/
public function getLastApiPath()
{
return $this->response->getApiPath();
}
/**
* @return int
*/
public function getLastHttpCode()
{
return $this->response->getHttpCode();
}
/**
* @return array
*/
public function getLastXHeaders()
{
return $this->response->getXHeaders();
}
/**
* @return array|object|null
*/
public function getLastBody()
{
return $this->response->getBody();
}
/**
* Resets the last response cache.
*/
public function resetLastResponse()
{
$this->response = new Response();
}
/**
* Make URLs for user browser navigation.
*
* @param string $path
* @param array $parameters
*
* @return string
*/
public function url($path, array $parameters)
{
$this->resetLastResponse();
$this->response->setApiPath($path);
$query = http_build_query($parameters);
return sprintf('%s/%s?%s', self::API_HOST, $path, $query);
}
/**
* Make /oauth/* requests to the API.
*
* @param string $path
* @param array $parameters
*
* @return array
* @throws TwitterOAuthException
*/
public function oauth($path, array $parameters = array())
{
$response = array();
$this->resetLastResponse();
$this->response->setApiPath($path);
$url = sprintf('%s/%s', self::API_HOST, $path);
$result = $this->oAuthRequest($url, 'POST', $parameters);
if ($this->getLastHttpCode() != 200) {
throw new TwitterOAuthException($result);
}
似乎是什么?我一直试图找到这个bug的解决方案好几个小时了,但是没有真正找到任何可能有任何帮助的东西。