有如下代码:
<pre><code> $oauth_nonce = md5(uniqid(rand(), true));
$oauth_timestamp = time();
$users_ids = implode(',',$users_ids['ids']);
$url = 'https://api.twitter.com/1.1/users/lookup.json';
$oauth_sig_text = self::sign_twitter($url,$oauth_token,false,$oauth_nonce,$oauth_timestamp,$users_ids);
$key = __TWITTERSECRET__ . '&' . $oauth_token_secret;
$signature = base64_encode(hash_hmac("sha1", $oauth_sig_text, $key, true));
$params = array(
'oauth_consumer_key' => __TWITTERKEY__,
'oauth_nonce' => $oauth_nonce,
'oauth_signature' => $signature,
'oauth_signature_method' => "HMAC-SHA1",
'oauth_timestamp' => $oauth_timestamp,
'oauth_token' => urlencode($oauth_token),
'oauth_version' => '1.0',
'user_id' => $users_ids
);
$url .= '?'.http_build_query($params);
$users_data = json_decode(file_get_contents($url),true);
echo '<pre>';
print_r($users_data);
echo '</pre>';
</code></pre>
<p>And signature:
<code></code></p><code>
<pre><code> protected function sign_twitter($url,$token,$verifier,$nonce,$timestamp,$ids=false){
$oauth_base_text = "GET&";
$oauth_base_text .= urlencode($url).'&';
$oauth_base_text .= urlencode('oauth_consumer_key='.__TWITTERKEY__.'&');
$oauth_base_text .= urlencode('oauth_nonce='.$nonce.'&');
$oauth_base_text .= urlencode('oauth_signature_method=HMAC-SHA1&');
$oauth_base_text .= urlencode('oauth_timestamp='.$timestamp."&");
$oauth_base_text .= urlencode('oauth_token='.$token."&");
$oauth_base_text .= urlencode('oauth_version=1.0&');
if ($verifier) {
$oauth_base_text .= urlencode("oauth_verifier=".$verifier."&");
$oauth_base_text .= urlencode("oauth_callback=".urlencode(__REDIRECT__)."&");
} else {
$oauth_base_text .= urlencode('user_id=' . $ids);
}
return $oauth_base_text;
}
</code></pre>
<p>I receive an error:</p>
<p><code>
Array([errors] => Array([0] => Array([message] => Could not authenticate you [code] => 32)))
</code></p>
<p>if you take a single identifier, the data are given ($users_ids = $users_ids['ids']['0']).
I have read a lot of topics on this issue, and everywhere it is written that the problem in comma that it should be encoded% 2C but it does not help ...</p>
<p>final url:</p>
</code><pre><code>https://api.twitter.com/1.1/users/lookup.json?oauth_consumer_key=Q6KMZzN7AAW******HoxmA&oauth_nonce=ab7e09e8466e0c9893acf3da32de9565&oauth_signature=rhUPhe1HgfcR%2Fr3nkTomuksWPzo%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1378367650&oauth_token=1727480588-IlvYrJZcRnp3dKScJiyZfEEMRpiqlVMTQTr764Q&oauth_version=1.0&user_id=93456690%2C81866717
</code></pre>
<p>signature:</p>
GET&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fusers%2Flookup.json&oauth_consumer_key%3DQ6KMZzN7AAW******HoxmA%26oauth_nonce%3Dab7e09e8466e0c9893acf3da32de9565%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1378367650%26oauth_token%3D1727480588-IlvYrJZcRnp3dKScJiyZfEEMRpiqlVMTQTr764Q%26oauth_version%3D1.0%26user_id%3D93456690%2C81866717
刚试过 POST 请求,没有帮助,所有完全相同的错误。
最佳答案
重新生成您的 Authtoken 并使用新的并再次检查。
关于php - 无法验证您的代码 32 twitter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18631069/
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我想安装一个带有一些身份验证的私有(private)Rubygem服务器。我希望能够使用公共(public)Ubuntu服务器托管内部gem。我读到了http://docs.rubygems.org/read/chapter/18.但是那个没有身份验证-如我所见。然后我读到了https://github.com/cwninja/geminabox.但是当我使用基本身份验证(他们在他们的Wiki中有)时,它会提示从我的服务器获取源。所以。如何制作带有身份验证的私有(private)Rubygem服务器?这是不可能的吗?谢谢。编辑:Geminabox问题。我尝试“捆绑”以安装新的gem..
如何在buildr项目中使用Ruby?我在很多不同的项目中使用过Ruby、JRuby、Java和Clojure。我目前正在使用我的标准Ruby开发一个模拟应用程序,我想尝试使用Clojure后端(我确实喜欢功能代码)以及JRubygui和测试套件。我还可以看到在未来的不同项目中使用Scala作为后端。我想我要为我的项目尝试一下buildr(http://buildr.apache.org/),但我注意到buildr似乎没有设置为在项目中使用JRuby代码本身!这看起来有点傻,因为该工具旨在统一通用的JVM语言并且是在ruby中构建的。除了将输出的jar包含在一个独特的、仅限ruby
在rails源中:https://github.com/rails/rails/blob/master/activesupport/lib/active_support/lazy_load_hooks.rb可以看到以下内容@load_hooks=Hash.new{|h,k|h[k]=[]}在IRB中,它只是初始化一个空哈希。和做有什么区别@load_hooks=Hash.new 最佳答案 查看rubydocumentationforHashnew→new_hashclicktotogglesourcenew(obj)→new_has
我希望我的UserPrice模型的属性在它们为空或不验证数值时默认为0。这些属性是tax_rate、shipping_cost和price。classCreateUserPrices8,:scale=>2t.decimal:tax_rate,:precision=>8,:scale=>2t.decimal:shipping_cost,:precision=>8,:scale=>2endendend起初,我将所有3列的:default=>0放在表格中,但我不想要这样,因为它已经填充了字段,我想使用占位符。这是我的UserPrice模型:classUserPrice回答before_val
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
我有一个表单,其中有很多字段取自数组(而不是模型或对象)。我如何验证这些字段的存在?solve_problem_pathdo|f|%>... 最佳答案 创建一个简单的类来包装请求参数并使用ActiveModel::Validations。#definedsomewhere,atthesimplest:require'ostruct'classSolvetrue#youcouldevencheckthesolutionwithavalidatorvalidatedoerrors.add(:base,"WRONG!!!")unlesss
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e