该脚本无法编译,但为什么呢?

发布于 2024-12-10 19:15:21 字数 2633 浏览 0 评论 0原文

该 ruby​​ 脚本不运行。 它会响应

/Users/superhappyfuntime/Desktop/twt.rb:25: undefined local variable or method `xsFEEyGKDPcnhJ5JoPJKg' for main:Object (NameError)
from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/twitter/configuration.rb:80:in `configure'
from /Users/superhappyfuntime/Desktop/twt.rb:24 

用户输入后,

This is 。我该如何修复它?另外,如果有帮助的话,这是脚本:

#!/usr/bin/ruby

require "rubygems"
require "twitter"


puts "Welcome! TwitNIX (A.K.A. 'clt') posts to Twitter from the command line!"


puts "your token, please:"

please = gets.chomp




puts "...aaand your secret_token:"

secret_token = gets.chomp

puts "You're Done!"


Twitter.configure do |config|
 config.consumer_key = xsFEEyGKDPcnhJ5JoPJKg
 config.consumer_secret = **CENSORED**
 config.oauth_token = please 
 config.oauth_token_secret = secret_token
 end


client = Twitter::Client.new



puts "Now,  post an update:"

update = gets

client.update("update")


puts "Now, post an update:"

update = gets

client.update("update")

一旦解决了这个问题,我的程序就应该完成了。请帮忙!

更新:现在显示:

/Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/faraday/response/raise_http_4xx.rb:12:in `on_complete': POST https://api.twitter.com/1/statuses/update.json: 401: Read-only application cannot POST (Twitter::Unauthorized)
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/response.rb:9:in `call'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/response.rb:62:in `on_complete'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/response.rb:8:in `call'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/request/url_encoded.rb:14:in `call'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/request/multipart.rb:13:in `call'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/faraday/request/twitter_oauth.rb:17:in `call'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/faraday/request/multipart_with_file.rb:18:in `call'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/connection.rb:207:in `run_request'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/connection.rb:94:in `post'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/twitter/request.rb:27:in `send'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/twitter/request.rb:27:in `request'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/twitter/request.rb:10:in `post'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/twitter/client/tweets.rb:45:in `update'
    from /Users/superhappyfuntime/Desktop/twt.rb:40

This ruby script does not run. It responds with

/Users/superhappyfuntime/Desktop/twt.rb:25: undefined local variable or method `xsFEEyGKDPcnhJ5JoPJKg' for main:Object (NameError)
from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/twitter/configuration.rb:80:in `configure'
from /Users/superhappyfuntime/Desktop/twt.rb:24 

This is after the user inputs.

How do I fix it? Also, if it helps, here is the script:

#!/usr/bin/ruby

require "rubygems"
require "twitter"


puts "Welcome! TwitNIX (A.K.A. 'clt') posts to Twitter from the command line!"


puts "your token, please:"

please = gets.chomp




puts "...aaand your secret_token:"

secret_token = gets.chomp

puts "You're Done!"


Twitter.configure do |config|
 config.consumer_key = xsFEEyGKDPcnhJ5JoPJKg
 config.consumer_secret = **CENSORED**
 config.oauth_token = please 
 config.oauth_token_secret = secret_token
 end


client = Twitter::Client.new



puts "Now,  post an update:"

update = gets

client.update("update")


puts "Now, post an update:"

update = gets

client.update("update")

Once this is fixed, my pogram should be done. PLEASE HELP!!

Update: Now it shows:

/Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/faraday/response/raise_http_4xx.rb:12:in `on_complete': POST https://api.twitter.com/1/statuses/update.json: 401: Read-only application cannot POST (Twitter::Unauthorized)
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/response.rb:9:in `call'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/response.rb:62:in `on_complete'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/response.rb:8:in `call'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/request/url_encoded.rb:14:in `call'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/request/multipart.rb:13:in `call'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/faraday/request/twitter_oauth.rb:17:in `call'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/faraday/request/multipart_with_file.rb:18:in `call'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/connection.rb:207:in `run_request'
    from /Library/Ruby/Gems/1.8/gems/faraday-0.7.5/lib/faraday/connection.rb:94:in `post'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/twitter/request.rb:27:in `send'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/twitter/request.rb:27:in `request'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/twitter/request.rb:10:in `post'
    from /Library/Ruby/Gems/1.8/gems/twitter-1.7.2/lib/twitter/client/tweets.rb:45:in `update'
    from /Users/superhappyfuntime/Desktop/twt.rb:40

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧情勿念 2024-12-17 19:15:21

向字符串添加 '' 单引号

Twitter.configure do |config|
 config.consumer_key = 'xsFEEyGKDPcnhJ5JoPJKg'
 config.consumer_secret = '**CENSORED**'

add '' single quotes to strings

Twitter.configure do |config|
 config.consumer_key = 'xsFEEyGKDPcnhJ5JoPJKg'
 config.consumer_secret = '**CENSORED**'
胡大本事 2024-12-17 19:15:21

更好的是,您可以重置您的 Twitter 消费者密钥和秘密。

www.ning.com/help/?p=5551

Better you can reset your twitter consumer key and secret.

www.ning.com/help/?p=5551
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文