twitter oauth:获取未定义索引:oauth_token_secret in [英] twitter oauth :geting undefined index: oauth_token_secret in

查看:78
本文介绍了twitter oauth:获取未定义索引:oauth_token_secret in的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试使用 oauth (PHP) 发布推文

Hi am trying to post tweets using oauth (PHP)

我在我的 Twitter 帐户中创建了该应用程序,

i created the application in my twitter account ,

我执行了一些开源脚本,但产生了以下错误,

i executed some open source script but that produce the below error,

Notice: Undefined index: oauth_token_secret in

如何解决这个问题

我的片段

require_once('twitterOAuth/twitterOAuth.php');
require_once('twitterOAuth/OAuth.php');


$consumer_key='q3fsdfsdfsdw';
$consumer_secret='rfsdfsdfsdfsdfdsfsdL';
$request_token='http://twitter.com/oauth/request_token';
$request_token_secret='5454545';
$oauth = new TwitterOAuth($consumer_key, $consumer_secret,
$request_token, $request_token_secret);

// Ask Twitter for an access token (and an access token secret)
$request = $oauth->getAccessToken();

$access_token = $request['amp;oauth_token'];
$access_token_secret = $request['oauth_token_secret'];=======> HERE AM GETTING TROUBLE

function getAccessToken($token = NULL, $pin = NULL)
{
    if ($pin)
        $r = $this->oAuthRequest($this->accessTokenURL(),
            array("oauth_verifier" => $pin));
    else
        $r = $this->oAuthRequest($this->accessTokenURL());

    $token = $this->oAuthParseResponse($r);
    $this->token = new OAuthConsumer($token['oauth_token'],
        $token['oauth_token_secret']);

    return $token;
}

我的完整错误在这里

Notice: Undefined index: oauth_token_secret in E:\wamp\www\source\oauth\twitterOAuth\twitteroauth.php on line 118

Notice: Undefined index: oauth_token_secret in E:\wamp\www\source\oauth\bharani.php on line 18

推荐答案

在您的 twitter 应用程序设置回调 URL"中,添加任何回调 URL,例如:
https://dev.twitter.com/

In your twitter application setting "Callback URL", add any callback url, for ex:
https://dev.twitter.com/

否则 twitter 会将您的应用程序视为桌面应用程序,您将收到错误消息:

Otherwise twitter will consider your application as desktop application and you will get error:

Desktop applications only support the oauth_callback value 'oob'

你的 php 脚本会给出如下错误:

and your php script will give errors like:

Notice: Undefined index: oauth_token in twitteroauth.php on line 80

但是通过从 php 脚本设置回调 url,它将覆盖回调 url 的默认占位符,并将您的应用程序视为基于 Web 的应用程序.

But by setting a callback url from php script it will overwrite the default placeholder of callback url and consider your application as a web based application.

这篇关于twitter oauth:获取未定义索引:oauth_token_secret in的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆