Php 有没有办法覆盖使用者密钥和使用者密钥
我将laravel与thujohn/twitter软件包一起使用。 但我希望无论何时任何用户注册,他们都会向我们提供消费者密钥和消费者秘密,我们将使用这些详细信息发布推文、收藏夹推文等 但是在thujohn/twitter软件包中,消费者密钥和消费者密钥只设置了一次,所有用户都可以使用,我希望每个注册用户都可以使用自己的消费者详细信息Php 有没有办法覆盖使用者密钥和使用者密钥,php,api,laravel,twitter,Php,Api,Laravel,Twitter,我将laravel与thujohn/twitter软件包一起使用。 但我希望无论何时任何用户注册,他们都会向我们提供消费者密钥和消费者秘密,我们将使用这些详细信息发布推文、收藏夹推文等 但是在thujohn/twitter软件包中,消费者密钥和消费者密钥只设置了一次,所有用户都可以使用,我希望每个注册用户都可以使用自己的消费者详细信息 任何人都知道同一个上的任何解决方案查看源代码您有重新配置方法: /** * Set new config values for the OAuth class
任何人都知道同一个上的任何解决方案查看源代码您有重新配置方法:
/**
* Set new config values for the OAuth class like different tokens.
*
* @param Array $config An array containing the values that should be overwritten.
*
* @return void
*/
public function reconfig($config)
{
// The consumer key and secret must always be included when reconfiguring
$config = array_merge($this->parent_config, $config);
parent::reconfigure($config);
return $this;
}
因此,您可以传递包含所需配置的阵列:
Twitter::reconfigure([
'consumer_key' => '',
'consumer_secret' => '',
'token' => '',
'secret' => '',
]);
然后,此配置将传递给父级,父级是另一个名为的库。下面是该库的代码:
public function reconfigure($config=array()) {
// default configuration options
$this->config = array_merge(
array(
// leave 'user_agent' blank for default, otherwise set this to
// something that clearly identifies your app
'user_agent' => '',
'host' => 'api.twitter.com',
'method' => 'GET',
'consumer_key' => '',
'consumer_secret' => '',
'token' => '',
'secret' => '',
// OAuth2 bearer token. This should already be URL encoded
'bearer' => '',
// oauth signing variables that are not dynamic
'oauth_version' => '1.0',
'oauth_signature_method' => 'HMAC-SHA1',
// you probably don't want to change any of these curl values
'curl_http_version' => CURL_HTTP_VERSION_1_1,
'curl_connecttimeout' => 30,
'curl_timeout' => 10,
// for security this should always be set to 2.
'curl_ssl_verifyhost' => 2,
// for security this should always be set to true.
'curl_ssl_verifypeer' => true,
// for security this should always be set to true.
'use_ssl' => true,
// you can get the latest cacert.pem from here http://curl.haxx.se/ca/cacert.pem
// if you're getting HTTP 0 responses, check cacert.pem exists and is readable
// without it curl won't be able to create an SSL connection
'curl_cainfo' => __DIR__ . DIRECTORY_SEPARATOR . 'cacert.pem',
'curl_capath' => __DIR__,
// in some cases (very very odd ones) the SSL version must be set manually.
// unless you know why your are changing this, you should leave it as false
// to allow PHP to determine the value for this setting itself.
'curl_sslversion' => false,
'curl_followlocation' => false, // whether to follow redirects or not
// support for proxy servers
'curl_proxy' => false, // really you don't want to use this if you are using streaming
'curl_proxyuserpwd' => false, // format username:password for proxy, if required
'curl_encoding' => '', // leave blank for all supported formats, else use gzip, deflate, identity etc
// streaming API configuration
'is_streaming' => false,
'streaming_eol' => "\r\n",
'streaming_metrics_interval' => 10,
// header or querystring. You should always use header!
// this is just to help me debug other developers implementations
'as_header' => true,
'force_nonce' => false, // used for checking signatures. leave as false for auto
'force_timestamp' => false, // used for checking signatures. leave as false for auto
),
$config
);
}
抱歉,我正在尝试您的代码并传递消费者密钥和消费者密钥,但我收到错误“[220]您的凭据不允许访问此资源。”同时我检查应用程序的权限,但设置正确。似乎正在设置消费者密钥和消费者密钥,是否确实为使用者密钥、使用者、令牌和机密设置了正确的值?试着激活twitter调试来检查日志,你的意思是说我们必须提供同一个用户的令牌和密码,该用户提供了他的消费者密钥,消费者密钥,除非你的应用程序上有什么东西,你是否请求用户授予你的应用程序权限Fabio你能告诉我,有没有任何可能的方法可以在我自己的消费者密钥和消费者密钥、令牌、消费者密钥和消费者密钥的基础上获取注册用户令牌和密钥(谁为我提供消费者密钥和消费者密钥),