GVKun编程网logo

Twitter API错误215(twitter错误10)

12

在本文中,我们将给您介绍关于TwitterAPI错误215的详细内容,并且为您解答twitter错误10的相关问题,此外,我们还将为您提供关于codebird-phpTwitter应用程序.验证Twi

在本文中,我们将给您介绍关于Twitter API错误215的详细内容,并且为您解答twitter错误10的相关问题,此外,我们还将为您提供关于codebird-php Twitter应用程序.验证Twitter API证书时出错77、Google App Engine,Twitter API Proxy,Mixero搭建Twi2tt图解、ios – SLRequest – Twitter返回代码215(错误的身份验证数据)、iphone – 如何使用twitter api v1.1(Twitter错误215)获取用户详细信息的知识。

本文目录一览:

Twitter API错误215(twitter错误10)

Twitter API错误215(twitter错误10)

今天,我们发现我的一位客户的Twitter提要已损坏。

我尝试切换为使用新的API 1.1,但出现以下错误:

{"errors":[{"message":"Bad Authentication data","code":215}]}

即使使用自己的示例也会产生相同的响应:

https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi&count=2

我正在参考以下文档。

https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline

知道这是怎么回事吗?

谢谢,Mikey

答案1

小编典典

因此,似乎Twitter的最新API 1.1 不允许 未经身份验证的访问-即使是看似公开的数据也是如此……就像时间轴上的最新3条推文一样。

我在此找到的最好的文章(提供了一个很好的解决方案)可以进行读取访问:

http://www.webdevdoor.com/php/authenticating-twitter-feed-timeline-
oauth/

我已经按照上面文章中的步骤进行操作,可以确认它的效果很好。

需要注意的有趣一点是,现在,因为您必须使用 访问令牌秘密密钥
;所有请求都必须使用服务器端脚本进行。在此之前,我使用jQuery直接在Twitters JSON
API上发出AJAX请求。现在,如果您希望使用Java脚本,则必须在自己的网站上请求AJAX动态脚本。

codebird-php Twitter应用程序.验证Twitter API证书时出错77

codebird-php Twitter应用程序.验证Twitter API证书时出错77

我正在尝试创建一个基于Twitter的身份验证的基本应用程序,并通过库codebird-PHP(https://github.com/mynetx/codebird-php)代表用户发布消息

我已经复制了自述文件中显示的示例代码,并使用我的应用程序的密钥和密码更改了YOURKEY和YOURSECRET.

一切都应该工作正常,但当我加载我的页面时,我收到一条消息说:
验证Twitter API证书时出错77.

我无法在谷歌的任何地方找到这种错误类型……意思很明显,但我不知道如何解决它.有什么想法吗?

代码如下:

require_once ('codebird.PHP');
\Codebird\Codebird::setConsumerKey('YOURKEY', 'YOURSECRET'); // I changed it to my   settings

$cb = \Codebird\Codebird::getInstance();
session_start();

if (! isset($_SESSION['oauth_token'])) {
// get the request token
$reply = $cb->oauth_requestToken(array(
    'oauth_callback' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']
));

// store the token
$cb->setToken($reply->oauth_token, $reply->oauth_token_secret);
$_SESSION['oauth_token'] = $reply->oauth_token;
$_SESSION['oauth_token_secret'] = $reply->oauth_token_secret;
$_SESSION['oauth_verify'] = true;

// redirect to auth website
$auth_url = $cb->oauth_authorize();
header('Location: ' . $auth_url);
die();

} elseif (isset($_GET['oauth_verifier']) && isset($_SESSION['oauth_verify'])) {
// verify the token
$cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
unset($_SESSION['oauth_verify']);

// get the access token
$reply = $cb->oauth_accesstoken(array(
    'oauth_verifier' => $_GET['oauth_verifier']
));

// store the token (which is different from the request token!)
$_SESSION['oauth_token'] = $reply->oauth_token;
$_SESSION['oauth_token_secret'] = $reply->oauth_token_secret;

// send to same URL, without oauth GET parameters
header('Location: ' . basename(__FILE__));
die();
}

// assign access token on each page load
$cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);

解决方法:

解决了,我必须有.pem,它没有包含在我下载的软件包中.结论:永远不要从不受信任的来源下载!

Google App Engine,Twitter API Proxy,Mixero搭建Twi2tt图解

Google App Engine,Twitter API Proxy,Mixero搭建Twi2tt图解

以前用Twitter都是通过代理访问网页或者使用第三方网站,今天http://www.php.cn/php/php-tp-install.html" target="_blank">安装了一个桌面客户端──Mixero,使用Google App Engine架设了一个Twitter API代理,就可以在桌面上随时看推发推了。网上一些假设教程不大准确或已过期,这里记录一下自己的操作过程。这些操作都

以前用twitter都是通过代理访问网页或者使用第三方网站,今天安装了一个桌面客户端──mixero,使用google app engine架设了一个twitter api代理,就可以在桌面上随时看推发推了。网上一些假设教程不大准确或已过期,这里记录一下自己的操作过程。这些操作都是在macos下进行的,在windows和linux下也都类似。

Mixero

Mixero是一个优秀的Twitter客户端,基于Adobe Air,支持各种操作系统,并且有中文版本。

由于众所周知的原因,Mixero必须通过代理才能与Twitter连线,下面的繁琐的步骤都是拜GFW所赐,Let''s Fuck Them!

架设Twitter API Proxy服务

Twitter API Proxy即Twitter API代理,通过代理使用Twitter API,可以实现Twitter的绝大部分功能。我们使用一个基于Google App Engine的开源项目birdnest来假设代理服务。

1. 申请和创建Google App Engine项目

用Gmail帐号登录Google App Engine,通过手机验证后,点击“Create an Applacation”,根据提示创建一个应用。

2. 下载Google App Engine SDK

通过SDK,我们可以方便的修改、测试和上传GAE项目。下载地址为:code.google.com/p/googleappengine/downloads/list,选择适合你操作系统的SDK并安装。启动后应该是这个样子:

3. 下载和修改birdnest

birdnest的代码发布在Google code上,使用SVN检出代码,嫌麻烦的可以直接下载我打包的文件,解压到一个目录,可以跳到下一步了。

检出代码有两点需要注意:

  • 1. 需要检出branches/gae目录下的代码

  • 2. 目前最新的r102版本code.py有问题,需要检出r97版本

在终端下的操作代码为:

建立目录并检出代码: [bash]# mkdir birdnest

svn checkout  birdnest.googlecode.com/svn/branches/gae birdnest/

svn up -r 97 birdnest/code.py

[/bash]4. 修改上传项目

打开birdnest目录,修改app.yaml文件,将第一行的nest改为你申请到的GAE项目ID。

打开刚才安装的GAE SDK,选择file-Add Existing Applacation,即导入存在的项目文件,选择刚才的birdnest目录。导入项目后,点击Deploy,填入Google帐号密码后,SDK就会将项目文件同步到GAE服务器。

5. 设置Mixero

现在需要做的工作就基本完成了,打开 http://你的ID.appspot.com/api/ 就应该看到了Twitter页面,如果不是,那就是有问题了。。

打开Mixero,填入帐号密码,点击右上角的齿轮,打开选项设置,在Twitter API一项中,填入上面的地址:

保存,刷新,就可以使用了。

以上就是Google App Engine,Twitter API Proxy,Mixero搭建Twi2tt图解的内容。

ios – SLRequest – Twitter返回代码215(错误的身份验证数据)

ios – SLRequest – Twitter返回代码215(错误的身份验证数据)

我在Instagram应用程序中有上传照片的应用程序.首先我的应用上传照片并返回链接.然后在状态消息中发送链接.当我在我的iPhone上测试时一切正常,但是当我在另一部iPhone上测试时,twitter会返回代码215错误的身份验证数据.什么想法可能是错的?谢谢回复.

- (void)tweet:(Nsstring *)identifier withCompletionHandler:(void (^)())completionHandler {
ACAccountStore *accountStore = [[ACAccountStore alloc] init];

// Create an account type that ensures Twitter accounts are retrieved.
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

// Request access from the user to use their Twitter accounts.
[accountStore requestAccesstoAccountsWithType:accountType withCompletionHandler:^(BOOL granted,NSError *error) {
    if(granted) {
        if (identifier) {
            // Get the list of Twitter accounts.
            NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];

            if ([accountsArray count] > 0) {
                // Grab the initial Twitter account to tweet from.
                NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/update.json"];
                NSDictionary *dict = [NSDictionary dictionaryWithObject:[Nsstring stringWithFormat:@"Check out this great flick on BLA BLA %@",[BLA_URL stringByAppendingFormat:@"/%@/%@",@"flick",identifier]]
                                                                 forKey:@"status"];

                SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
                                                        requestMethod:SLRequestMethodPOST
                                                                  URL:url
                                                           parameters:dict];
                [request setAccount:[accountsArray lastObject]];
                [request performRequestWithHandler:^(NSData *responseData,NSHTTPURLResponse *urlResponse,NSError *error) {
                    if ([urlResponse statusCode] == 200) {
                        NSLog(@"TWEEET!");

                    }
                    else { 
                        NSError *jsonError;
                        id data = [NSJSONSerialization JSONObjectWithData:responseData
                                                                  options:NSJSONReadingMutableLeaves
                                                                    error:&jsonError];

                        dispatch_async(dispatch_get_main_queue(),^{
                            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Twitter response"
                                                                                message:[Nsstring stringWithFormat:@"%d S: %d %@",[error code],[urlResponse statusCode],data]
                                                                               delegate:self
                                                                      cancelButtonTitle:@"Ok"
                                                                      otherButtonTitles:nil];
                            NSLog(@"NOOO TWEEET!");
                            [alertView show];
                            completionHandler();
                        });
                    }
                }];
...

和预检功能:

- (IBAction)twitterButtonTapped:(id)sender {
if ([self.twitterButton isSelected]) {
    [self.twitterButton setSelected:NO];
}
else {
    [self.twitterButton setSelected:YES];

    ACAccountStore *accountStore = [[ACAccountStore alloc] init];
    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

    [accountStore requestAccesstoAccountsWithType:accountType withCompletionHandler:^(BOOL granted,NSError *error) {
        if (!granted) {
            [self.twitterButton setSelected:NO];

            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Twitter access"
                                                                message:@"Please make sure you have allowed twitter for BLA BLA in your Settings."
                                                               delegate:self
                                                      cancelButtonTitle:@"Ok"
                                                      otherButtonTitles:nil];
            [alertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO];
        }
    }];
}

}

解决方法

好的,我有答案!问题是其他iPhone的帐户数据不完整 – 您必须在设置应用中填写用户名和密码.

iphone – 如何使用twitter api v1.1(Twitter错误215)获取用户详细信息

iphone – 如何使用twitter api v1.1(Twitter错误215)获取用户详细信息

我使用twitter提供的twitter api来获取详细信息
不能执行它,甚至试图通过认证数据
像消费者密钥,消费者密钥,令牌,但结果是一样的.
我能够登录和接收twitter身份验证令牌,但无法获取用户详细信息.
以下代码由我使用(我正在使用MGtwitter引擎):

NSMutableuRLRequest *request =[[NSMutableuRLRequest alloc]initWithURL:[NSURL URLWithString:[Nsstring stringWithFormat:@"https://api.twitter.com/1.1/users/show.json?screen_name=%@",username]]];

NSData *returnData = [ NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil ];

Nsstring *returnString = [[Nsstring alloc]initWithData:returnData encoding:NSUTF8StringEncoding];
    NSError *err = nil;

twitterLogin = [NSJSONSerialization JSONObjectWithData:[returnString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&err];

错误如下所示:

errors = (
{
    code = 215;
    message = "Bad Authentication data";
} );

解决方法

首先,您需要验证您的请求(获取权限).

第二,请参阅以下步骤:

下载FHSTwitterEngine Twitter图书馆.

2.将文件夹“FHSTwitterEngine”添加到您的项目中,然后添加#import“FHSTwitterEngine.h”.

3.将SystemConfiguration.framework添加到您的项目中.

Usage : 1.in the [ViewDidLoad] add the following code.

UIButton *logIn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    logIn.frame = CGRectMake(100,100,100);
    [logIn setTitle:@"Login" forState:UIControlStatenormal];
    [logIn addTarget:self action:@selector(showLoginWindow:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:logIn];

[[FHSTwitterEngine sharedEngine]permanentlySetConsumerKey:@"<consumer_key>" andSecret:@"<consumer_secret>"];
    [[FHSTwitterEngine sharedEngine]setDelegate:self];

并且不要忘记导入代理FHSTwitterEngineAccesstokenDelegate.

  1. you need to get the permission for your request,with the following method which will present Login window:
- (void)showLoginWindow:(id)sender {
    [[FHSTwitterEngine sharedEngine]showOAuthLoginControllerFromViewController:self withCompletion:^(BOOL success) {
        NSLog(success?@"L0L success":@"O noes!!! Loggen faylur!!!");
    }];
}

当登录窗口出现时,输入您的Twitter用户名和密码来验证您的请求.

  1. add the following methods to your code:
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [[FHSTwitterEngine sharedEngine]loadAccesstoken];
    Nsstring *username = [[FHSTwitterEngine sharedEngine]loggedInUsername];// self.engine.loggedInUsername;
    if (username.length > 0) {
        lbl.text = [Nsstring stringWithFormat:@"Logged in as %@",username];
        [self listResults];


    } else {
        lbl.text = @"You are not logged in.";
    }

}
- (void)storeAccesstoken:(Nsstring *)accesstoken {
    [[NSUserDefaults standardUserDefaults]setobject:accesstoken forKey:@"SavedAccessHTTPBody"];
}

- (Nsstring *)loadAccesstoken {
    return [[NSUserDefaults standardUserDefaults]objectForKey:@"SavedAccessHTTPBody"];
}

4.Now you are ready to get your request,with the following method(in this method I created a Twitter search for some Hashtag,to get the screen_name for example):

- (void)listResults {

    dispatch_async(GCDBackgroundThread,^{
        @autoreleasepool {
            [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

        // the following line contains a FHSTwitterEngine method wich do the search.

            dict = [[FHSTwitterEngine sharedEngine]searchTweetsWithQuery:@"#iOS" count:100 resultType:FHSTwitterEngineResultTypeRecent unil:nil sinceID:nil maxID:nil];
          // NSLog(@"%@",dict);
            NSArray *results = [dict objectForKey:@"statuses"];

          //  NSLog(@"array text = %@",results);
            for (NSDictionary *item in results) {
                NSLog(@"text == %@",[item objectForKey:@"text"]);
                NSLog(@"name == %@",[[item objectForKey:@"user"]objectForKey:@"name"]);
                NSLog(@"screen name == %@",[[item objectForKey:@"user"]objectForKey:@"screen_name"]);
                NSLog(@"pic == %@",[[item objectForKey:@"user"]objectForKey:@"profile_image_url_https"]);
            }

            dispatch_sync(GCDMainThread,^{
                @autoreleasepool {
                    UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"Complete!" message:@"Your list of followers has been fetched" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                    [av show];
                    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
                }
            });
        }
    });
}

就这样.
我从搜索查询中获取了screen_name,您可以使用以下方法获取用户的时间轴:

// statuses/user_timeline
- (id)getTimelineForUser:(Nsstring *)user isID:(BOOL)isID count:(int)count;
- (id)getTimelineForUser:(Nsstring *)user isID:(BOOL)isID count:(int)count sinceID:(Nsstring *)sinceID maxID:(Nsstring *)maxID;

而不是上面的搜索方法.

注意:请参阅FHSTwitterEngine.h以了解需要使用的方法.
注意:获取< consumer_key>和< consumer_secret>您需要访问这个link 在Twitter上注册您的应用程序.

关于Twitter API错误215twitter错误10的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于codebird-php Twitter应用程序.验证Twitter API证书时出错77、Google App Engine,Twitter API Proxy,Mixero搭建Twi2tt图解、ios – SLRequest – Twitter返回代码215(错误的身份验证数据)、iphone – 如何使用twitter api v1.1(Twitter错误215)获取用户详细信息的相关信息,请在本站寻找。

本文标签: