gpt4 book ai didi

php - 无法验证您的代码 32 twitter

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:50:20 25 4
gpt4 key购买 nike

有如下代码:



<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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com