【TwitterAPI】「tmhOAuth-master」の認証オブジェクトの中身
PHPで「tmhOAuth-master」を使ってTwitterAPIを叩くときに作成する認証オブジェクトあれこれの中身を個人的な開発のためにメモしています(毎度毎度忘れてしまうので開発ストレスを減らすため)。
「tmhOAuth-master」を使った認証オブジェクトの作成時
TwitterAPIライブラリである「tmhOAuth-master」を使って認証オブジェクトを作成するときの簡易的なPHPコードは以下です。
//TwitterAPIの各種認証情報
$consumer_key = "**********";
$consumer_secret = "**********";
//「tmhOAuth-master」認証ライブラリのインクルード
require_once(dirname(__FILE__) . "/" . "./tmhOAuth-master/tmhOAuth.php");
//認証オブジェクトの作成
$oauth_object = new tmhOauth(array('consumer_key'=>$consumer_key, 'consumer_secret'=>$consumer_secret));
認証オブジェクトの中身
このときの「$oauth_object」には次のような情報が格納されています。
tmhOAuth Object
(
[response] => Array
(
)
[buffer] =>
[config] => Array
(
[user_agent] => tmhOAuth 0.8.4+SSL - //github.com/themattharris/tmhOAuth
[host] => api.twitter.com
[method] => GET
[consumer_key] => **********(APIを叩くために指定したアプリのConsumer Key)
[consumer_secret] => **********(APIを叩くために指定したアプリのConsumer Secret)
[token] =>
[secret] =>
[bearer] =>
[oauth_version] => 1.0
[oauth_signature_method] => HMAC-SHA1
[curl_http_version] => 2
[curl_connecttimeout] => 30
[curl_timeout] => 10
[curl_ssl_verifyhost] => 2
[curl_ssl_verifypeer] => 1
[use_ssl] => 1
[curl_cainfo] => /home/***/www/***/***/***/tmhOAuth-master/cacert.pem(「tmhOAuth-master」を置いているディレクトリ)
[curl_capath] => /home/***/www/***/***/***/tmhOAuth-master(「tmhOAuth-master」を置いているディレクトリ)
[curl_sslversion] =>
[curl_followlocation] =>
[curl_proxy] =>
[curl_proxyuserpwd] =>
[curl_encoding] =>
[is_streaming] =>
[streaming_eol] =>
[streaming_metrics_interval] => 10
[as_header] => 1
[force_nonce] =>
[force_timestamp] =>
)
[request_settings] => Array
(
[params] => Array
(
)
[headers] => Array
(
)
[with_user] => 1
[multipart] =>
)
)
「tmhOAuth-master」を使ったツイッター認証情報の取得時
認証オブジェクトを作成し、ツイッター認証情報「oauth_token」と「oauth_token_secret」を取得するための簡易的なPHPコードは以下です。
//TwitterAPIの各種認証情報
$consumer_key = "**********";
$consumer_secret = "**********";
//「tmhOAuth-master」認証ライブラリのインクルード
require_once(dirname(__FILE__) . "/" . "./tmhOAuth-master/tmhOAuth.php");
//認証オブジェクトの作成
$oauth_object = new tmhOauth(array('consumer_key'=>$consumer_key, 'consumer_secret'=>$consumer_secret));
//リクエストオプションの組立
$params = array(
'oauth_callback' => $_SERVER['HTTP_REFERER'],
'x_auth_access_type' => 'write',
);
//リクエスト
$code = $oauth_object->request(
'POST',
$oauth_object->url('oauth/request_token', ''),
$params
);
認証オブジェクトの中身
このときの「$oauth_object」には次のような情報が格納されています。
tmhOAuth Object
(
[response] => Array
(
[raw] => HTTP/1.1 200 OK
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-encoding: gzip
content-length: 129
content-security-policy: default-src 'none'; connect-src 'self'; font-src https://abs.twimg.com https://abs-0.twimg.com data:; frame-src 'self' twitter:; img-src https://abs.twimg.com https://*.twimg.com https://pbs.twimg.com data:; media-src 'none'; object-src 'none'; script-src https://abs.twimg.com https://abs-0.twimg.com https://twitter.com https://mobile.twitter.com; style-src https://abs.twimg.com https://abs-0.twimg.com; report-uri https://twitter.com/i/csp_report?a=NVQWGYLXFVWG6Z3JNY%3D%3D%3D%3D%3D%3D&ro=false;
content-type: text/html;charset=utf-8
date: Mon, 17 Apr 2017 08:48:42 GMT
expires: Tue, 31 Mar 1981 05:00:00 GMT
last-modified: Mon, 17 Apr 2017 08:48:42 GMT
ml: S
pragma: no-cache
server: tsa_m
set-cookie: guest_id=v1%3A149241892197575117; Domain=.twitter.com; Path=/; Expires=Wed, 17-Apr-2019 08:48:42 UTC
status: 200 OK
strict-transport-security: max-age=631138519
x-connection-hash: 0bfc19220c3789dc46540641990159fe
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-response-time: 180
x-transaction: 00c513dc00121a95
x-tsa-request-body-time: 0
x-twitter-response-tags: BouncerCompliant
x-ua-compatible: IE=edge,chrome=1
x-xss-protection: 1; mode=block
oauth_token=W-5eegAAAAAAe-QpAAABW3sZhgg&oauth_token_secret=Gqm9oVzGOBeDaerIlLjZuWl2WH7Zqnzw&oauth_callback_confirmed=true
[headers] => Array
(
[HTTP/1.1 200 OK] =>
[cache-control] => no-cache, no-store, must-revalidate, pre-check=0, post-check=0
[content-encoding] => gzip
[content-length] => 129
[content-security-policy] => default-src 'none'; connect-src 'self'; font-src https://abs.twimg.com https://abs-0.twimg.com data:; frame-src 'self' twitter:; img-src https://abs.twimg.com https://*.twimg.com https://pbs.twimg.com data:; media-src 'none'; object-src 'none'; script-src https://abs.twimg.com https://abs-0.twimg.com https://twitter.com https://mobile.twitter.com; style-src https://abs.twimg.com https://abs-0.twimg.com; report-uri https://twitter.com/i/csp_report?a=NVQWGYLXFVWG6Z3JNY%3D%3D%3D%3D%3D%3D&ro=false;
[content-type] => text/html;charset=utf-8
[date] => Mon, 17 Apr 2017 08:48:42 GMT
[expires] => Tue, 31 Mar 1981 05:00:00 GMT
[last-modified] => Mon, 17 Apr 2017 08:48:42 GMT
[ml] => S
[pragma] => no-cache
[server] => tsa_m
[set-cookie] => guest_id=v1%3A149241892197575117; Domain=.twitter.com; Path=/; Expires=Wed, 17-Apr-2019 08:48:42 UTC
[status] => 200 OK
[strict-transport-security] => max-age=631138519
[x-connection-hash] => 0bfc19220c3789dc46540641990159fe
[x-content-type-options] => nosniff
[x-frame-options] => SAMEORIGIN
[x-response-time] => 180
[x-transaction] => 00c513dc00121a95
[x-tsa-request-body-time] => 0
[x-twitter-response-tags] => BouncerCompliant
[x-ua-compatible] => IE=edge,chrome=1
[x-xss-protection] => 1; mode=block
[] =>
)
=> 200
[response] => oauth_token=W-5eegAAAAAAe-QpAAABW3sZhgg&oauth_token_secret=Gqm9oVzGOBeDaerIlLjZuWl2WH7Zqnzw&oauth_callback_confirmed=true
[info] => Array
(
[url] => https://api.twitter.com/oauth/request_token
[content_type] => text/html;charset=utf-8
[http_code] => 200
[header_size] => 1356
[request_size] => 587
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.207786
[namelookup_time] => 0.00253
[connect_time] => 0.004632
[pretransfer_time] => 0.025151
[size_upload] => 24
[size_download] => 129
[speed_download] => 620
[speed_upload] => 115
[download_content_length] => 129
[upload_content_length] => 24
[starttransfer_time] => 0.20773
[redirect_time] => 0
[certinfo] => Array
(
)
[primary_ip] => 104.244.42.130
[primary_port] => 443
[local_ip] => ***.***.***.***
[local_port] => 43005
[redirect_url] =>
[request_header] => POST /oauth/request_token HTTP/1.1
Host: api.twitter.com
User-Agent: tmhOAuth 0.8.4+SSL - //github.com/themattharris/tmhOAuth
Accept: */*
Accept-Encoding: deflate, gzip
Authorization: OAuth oauth_callback="http%3A%2F%2Fysklog.net%2Ftool%2Ftwitter-delete-tweet.html", oauth_consumer_key="**********(APIを叩くために指定したアプリのConsumer Key)", oauth_nonce="0ccb5b96b07d7e1beac9e0954db07a8c", oauth_signature="%2BbHi9kcOmA2BJSFBmxm0HKwe4Io%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1492418921", oauth_version="1.0"
Content-Length: 24
Content-Type: application/x-www-form-urlencoded
)
[error] =>
[errno] => 0
)
[buffer] =>
[config] => Array
(
[user_agent] => tmhOAuth 0.8.4+SSL - //github.com/themattharris/tmhOAuth
[host] => api.twitter.com
[method] => GET
[consumer_key] => **********(APIを叩くために指定したアプリのConsumer Key)
[consumer_secret] => **********(APIを叩くために指定したアプリのConsumer Secret)
[token] =>
[secret] =>
[bearer] =>
[oauth_version] => 1.0
[oauth_signature_method] => HMAC-SHA1
[curl_http_version] => 2
[curl_connecttimeout] => 30
[curl_timeout] => 10
[curl_ssl_verifyhost] => 2
[curl_ssl_verifypeer] => 1
[use_ssl] => 1
[curl_cainfo] => /home/***/www/***/***/***/tmhOAuth-master/cacert.pem(「tmhOAuth-master」を置いているディレクトリ)
[curl_capath] => /home/***/www/***/***/***/tmhOAuth-master(「tmhOAuth-master」を置いているディレクトリ)
[curl_sslversion] =>
[curl_followlocation] =>
[curl_proxy] =>
[curl_proxyuserpwd] =>
[curl_encoding] =>
[is_streaming] =>
[streaming_eol] =>
[streaming_metrics_interval] => 10
[as_header] => 1
[force_nonce] =>
[force_timestamp] =>
)
[request_settings] => Array
(
[params] => Array
(
[oauth_callback] => http://ysklog.net/tool/twitter-delete-tweet.html
[x_auth_access_type] => write
)
[headers] => Array
(
[Authorization] => OAuth oauth_callback="http%3A%2F%2Fysklog.net%2Ftool%2Ftwitter-delete-tweet.html", oauth_consumer_key="**********(APIを叩くために指定したアプリのConsumer Key)", oauth_nonce="0ccb5b96b07d7e1beac9e0954db07a8c", oauth_signature="%2BbHi9kcOmA2BJSFBmxm0HKwe4Io%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1492418921", oauth_version="1.0"
)
[with_user] => 1
[multipart] =>
[method] => POST
[without_bearer] =>
[url] => https://api.twitter.com/oauth/request_token
[oauth1_params] => Array
(
[oauth_callback] => http%3A%2F%2Fysklog.net%2Ftool%2Ftwitter-delete-tweet.html
[oauth_consumer_key] => **********(APIを叩くために指定したアプリのConsumer Key)
[oauth_nonce] => 0ccb5b96b07d7e1beac9e0954db07a8c
[oauth_signature] => %2BbHi9kcOmA2BJSFBmxm0HKwe4Io%3D
[oauth_signature_method] => HMAC-SHA1
[oauth_timestamp] => 1492418921
[oauth_version] => 1.0
)
[prepared_params] => Array
(
[x_auth_access_type] => write
)
[basestring_params] => oauth_callback=http%3A%2F%2Fysklog.net%2Ftool%2Ftwitter-delete-tweet.html&oauth_consumer_key=**********(APIを叩くために指定したアプリのConsumer Key)&oauth_nonce=0ccb5b96b07d7e1beac9e0954db07a8c&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1492418921&oauth_version=1.0&x_auth_access_type=write
[postfields] => x_auth_access_type=write
[basestring] => POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_callback%3Dhttp%253A%252F%252Fysklog.net%252Ftool%252Ftwitter-delete-tweet.html%26oauth_consumer_key%3D**********(APIを叩くために指定したアプリのConsumer Key)%26oauth_nonce%3D0ccb5b96b07d7e1beac9e0954db07a8c%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1492418921%26oauth_version%3D1.0%26x_auth_access_type%3Dwrite
[signing_key] => **********(APIを叩くために指定したアプリのConsumer Secret)&
)
)
「ツイートの一括削除ツール!」で言うと、ページにアクセスして、「ツイッター認証」ボタンが表示されるまでの流れがここまで。
「tmhOAuth-master」を使ったユーザー認証のためのオブジェクト作成時
ここまでの
- 「oauth_token」
- 「oauth_token_secret」
はツイッター認証情報(ツイッターサーバーとの一時的な認証情報)の取得をしただけなので、引き続きユーザー認証情報を取得する必要がある。
これも同じように「tmhOAuth-master」を使ってまずは認証オブジェクトを作成する。
//TwitterAPIの各種認証情報
$consumer_key = "**********";
$consumer_secret = "**********";
$oauth_token = "**********";
$oauth_token_secret = "**********";
//「tmhOAuth-master」認証ライブラリのインクルード
require_once(dirname(__FILE__) . "/" . "./tmhOAuth-master/tmhOAuth.php");
//認証オブジェクトの作成
$oauth_object = new tmhOauth(array('consumer_key'=>$consumer_key, 'consumer_secret'=>$consumer_secret, 'token'=>$oauth_token, 'secret'=>$oauth_token_secret));
認証オブジェクトの中身
このときの「$oauth_object」には次のような情報が格納されています。
tmhOAuth Object
(
[response] => Array
(
)
[buffer] =>
[config] => Array
(
[user_agent] => tmhOAuth 0.8.4+SSL - //github.com/themattharris/tmhOAuth
[host] => api.twitter.com
[method] => GET
[consumer_key] => **********(APIを叩くために指定したアプリのConsumer Key)
[consumer_secret] => **********(APIを叩くために指定したアプリのConsumer Secret)
[token] => **********(ツイッターサーバーと一時的な認証をするためのトークン)
[secret] => **********(ツイッターサーバーと一時的な認証をするためのトークンシークレット)
[bearer] =>
[oauth_version] => 1.0
[oauth_signature_method] => HMAC-SHA1
[curl_http_version] => 2
[curl_connecttimeout] => 30
[curl_timeout] => 10
[curl_ssl_verifyhost] => 2
[curl_ssl_verifypeer] => 1
[use_ssl] => 1
[curl_cainfo] => /home/***/www/***/***/***/tmhOAuth-master/cacert.pem(「tmhOAuth-master」を置いているディレクトリ)
[curl_capath] => /home/***/www/***/***/***/tmhOAuth-master(「tmhOAuth-master」を置いているディレクトリ)
[curl_sslversion] =>
[curl_followlocation] =>
[curl_proxy] =>
[curl_proxyuserpwd] =>
[curl_encoding] =>
[is_streaming] =>
[streaming_eol] =>
[streaming_metrics_interval] => 10
[as_header] => 1
[force_nonce] =>
[force_timestamp] =>
)
[request_settings] => Array
(
[params] => Array
(
)
[headers] => Array
(
)
[with_user] => 1
[multipart] =>
)
)
「tmhOAuth-master」を使ったユーザー認証情報の取得時
認証オブジェクトを作成し、ユーザー認証情報「access_token」と「access_token_secret」を取得するための簡易的なPHPコードは以下です。
//TwitterAPIの各種認証情報
$consumer_key = "**********";
$consumer_secret = "**********";
$oauth_token = "**********";
$oauth_token_secret = "**********";
$oauth_verifier = "**********"; //ツイッター認証ボタンをクリックした後にURLのパラメーターについてくるもの
//「tmhOAuth-master」認証ライブラリのインクルード
require_once(dirname(__FILE__) . "/" . "./tmhOAuth-master/tmhOAuth.php");
//認証オブジェクトの作成
$oauth_object = new tmhOauth(array('consumer_key'=>$consumer_key, 'consumer_secret'=>$consumer_secret, 'token'=>$oauth_token, 'secret'=>$oauth_token_secret));
//リクエストオプションの組立
$params = array(
'oauth_verifier' => $oauth_verifier,
);
//リクエスト
$code = $oauth_object->request(
'POST',
$oauth_object->url('oauth/access_token', ''),
$params
);
認証オブジェクトの中身
このときの「$oauth_object」には次のような情報が格納されています。
tmhOAuth Object
(
[response] => Array
(
[raw] => HTTP/1.1 200 OK
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-encoding: gzip
content-length: 184
content-security-policy: default-src 'none'; connect-src 'self'; font-src https://abs.twimg.com https://abs-0.twimg.com data:; frame-src 'self' twitter:; img-src https://abs.twimg.com https://*.twimg.com https://pbs.twimg.com data:; media-src 'none'; object-src 'none'; script-src https://abs.twimg.com https://abs-0.twimg.com https://twitter.com https://mobile.twitter.com; style-src https://abs.twimg.com https://abs-0.twimg.com; report-uri https://twitter.com/i/csp_report?a=NVQWGYLXFVWG6Z3JNY%3D%3D%3D%3D%3D%3D&ro=false;
content-type: text/html;charset=utf-8
date: Mon, 17 Apr 2017 10:14:41 GMT
expires: Tue, 31 Mar 1981 05:00:00 GMT
last-modified: Mon, 17 Apr 2017 10:14:41 GMT
ml: S
pragma: no-cache
server: tsa_m
set-cookie: guest_id=v1%3A149242408164701584; Domain=.twitter.com; Path=/; Expires=Wed, 17-Apr-2019 10:14:41 UTC
status: 200 OK
strict-transport-security: max-age=631138519
x-connection-hash: 25fe99426ed029728fd40a5d470c5e63
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-response-time: 430
x-transaction: 00ff8c67004bf9c5
x-twitter-response-tags: BouncerCompliant
x-ua-compatible: IE=edge,chrome=1
x-xss-protection: 1; mode=block
oauth_token=**********(ユーザーのAccess Token)&oauth_token_secret=**********(ユーザーのAccess Token Secret)&user_id=**********(ユーザーID)&screen_name=**********(ユーザーネーム)&x_auth_expires=0
[headers] => Array
(
[HTTP/1.1 200 OK] =>
[cache-control] => no-cache, no-store, must-revalidate, pre-check=0, post-check=0
[content-encoding] => gzip
[content-length] => 184
[content-security-policy] => default-src 'none'; connect-src 'self'; font-src https://abs.twimg.com https://abs-0.twimg.com data:; frame-src 'self' twitter:; img-src https://abs.twimg.com https://*.twimg.com https://pbs.twimg.com data:; media-src 'none'; object-src 'none'; script-src https://abs.twimg.com https://abs-0.twimg.com https://twitter.com https://mobile.twitter.com; style-src https://abs.twimg.com https://abs-0.twimg.com; report-uri https://twitter.com/i/csp_report?a=NVQWGYLXFVWG6Z3JNY%3D%3D%3D%3D%3D%3D&ro=false;
[content-type] => text/html;charset=utf-8
[date] => Mon, 17 Apr 2017 10:14:41 GMT
[expires] => Tue, 31 Mar 1981 05:00:00 GMT
[last-modified] => Mon, 17 Apr 2017 10:14:41 GMT
[ml] => S
[pragma] => no-cache
[server] => tsa_m
[set-cookie] => guest_id=v1%3A149242408164701584; Domain=.twitter.com; Path=/; Expires=Wed, 17-Apr-2019 10:14:41 UTC
[status] => 200 OK
[strict-transport-security] => max-age=631138519
[x-connection-hash] => 25fe99426ed029728fd40a5d470c5e63
[x-content-type-options] => nosniff
[x-frame-options] => SAMEORIGIN
[x-response-time] => 430
[x-transaction] => 00ff8c67004bf9c5
[x-twitter-response-tags] => BouncerCompliant
[x-ua-compatible] => IE=edge,chrome=1
[x-xss-protection] => 1; mode=block
[] =>
)
=> 200
[response] => oauth_token=**********(ユーザーのAccess Token)&oauth_token_secret=**********(ユーザーのAccess Token Secret)&user_id=**********(ユーザーID)&screen_name=**********(ユーザーネーム)&x_auth_expires=0
[info] => Array
(
[url] => https://api.twitter.com/oauth/access_token
[content_type] => text/html;charset=utf-8
[http_code] => 200
[header_size] => 1328
[request_size] => 546
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.455398
[namelookup_time] => 0.002409
[connect_time] => 0.003962
[pretransfer_time] => 0.022682
[size_upload] => 0
[size_download] => 184
[speed_download] => 404
[speed_upload] => 0
[download_content_length] => 184
[upload_content_length] => -1
[starttransfer_time] => 0.455327
[redirect_time] => 0
[certinfo] => Array
(
)
[primary_ip] => 104.244.42.66
[primary_port] => 443
[local_ip] => ***.***.***.***
[local_port] => 18863
[redirect_url] =>
[request_header] => POST /oauth/access_token HTTP/1.1
Host: api.twitter.com
User-Agent: tmhOAuth 0.8.4+SSL - //github.com/themattharris/tmhOAuth
Accept: */*
Accept-Encoding: deflate, gzip
Authorization: OAuth oauth_consumer_key="**********(APIを叩くために指定したアプリのConsumer Key)", oauth_nonce="0e5d6b7d94389876756828969162b08d", oauth_signature="L3%2F%2BciQScEsXfK3s2RilvxqMJUE%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1492424081", oauth_token="4DsPdQAAAAAAe-QpAAABW3tn9zk", oauth_verifier="qPsG9R7gRJAtqTFDsk8YVblHWgr1wzdJ", oauth_version="1.0"
Content-Length: 0
)
[error] =>
[errno] => 0
)
[buffer] =>
[config] => Array
(
[user_agent] => tmhOAuth 0.8.4+SSL - //github.com/themattharris/tmhOAuth
[host] => api.twitter.com
[method] => GET
[consumer_key] =>**********(APIを叩くために指定したアプリのConsumer Key)
[consumer_secret] =>**********(APIを叩くために指定したアプリのConsumer Secret)
[token] => 4DsPdQAAAAAAe-QpAAABW3tn9zk
[secret] => KLrLAKuKB8WKC8CNBAH4j09cde0aXEac
[bearer] =>
[oauth_version] => 1.0
[oauth_signature_method] => HMAC-SHA1
[curl_http_version] => 2
[curl_connecttimeout] => 30
[curl_timeout] => 10
[curl_ssl_verifyhost] => 2
[curl_ssl_verifypeer] => 1
[use_ssl] => 1
[curl_cainfo] => /home/***/www/***/***/***/tmhOAuth-master/cacert.pem(「tmhOAuth-master」を置いているディレクトリ)
[curl_capath] => /home/***/www/***/***/***/tmhOAuth-master(「tmhOAuth-master」を置いているディレクトリ)
[curl_sslversion] =>
[curl_followlocation] =>
[curl_proxy] =>
[curl_proxyuserpwd] =>
[curl_encoding] =>
[is_streaming] =>
[streaming_eol] =>
[streaming_metrics_interval] => 10
[as_header] => 1
[force_nonce] =>
[force_timestamp] =>
)
[request_settings] => Array
(
[params] => Array
(
[oauth_verifier] => qPsG9R7gRJAtqTFDsk8YVblHWgr1wzdJ
)
[headers] => Array
(
[Authorization] => OAuth oauth_consumer_key="**********(APIを叩くために指定したアプリのConsumer Key)", oauth_nonce="0e5d6b7d94389876756828969162b08d", oauth_signature="L3%2F%2BciQScEsXfK3s2RilvxqMJUE%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1492424081", oauth_token="4DsPdQAAAAAAe-QpAAABW3tn9zk", oauth_verifier="qPsG9R7gRJAtqTFDsk8YVblHWgr1wzdJ", oauth_version="1.0"
)
[with_user] => 1
[multipart] =>
[method] => POST
[without_bearer] =>
[url] => https://api.twitter.com/oauth/access_token
[oauth1_params] => Array
(
[oauth_consumer_key] =>**********(APIを叩くために指定したアプリのConsumer Key)
[oauth_nonce] => 0e5d6b7d94389876756828969162b08d
[oauth_signature] => L3%2F%2BciQScEsXfK3s2RilvxqMJUE%3D
[oauth_signature_method] => HMAC-SHA1
[oauth_timestamp] => 1492424081
[oauth_token] => 4DsPdQAAAAAAe-QpAAABW3tn9zk
[oauth_verifier] => qPsG9R7gRJAtqTFDsk8YVblHWgr1wzdJ
[oauth_version] => 1.0
)
[prepared_params] => Array
(
)
[basestring_params] => oauth_consumer_key=**********(APIを叩くために指定したアプリのConsumer Key)&oauth_nonce=0e5d6b7d94389876756828969162b08d&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1492424081&oauth_token=4DsPdQAAAAAAe-QpAAABW3tn9zk&oauth_verifier=qPsG9R7gRJAtqTFDsk8YVblHWgr1wzdJ&oauth_version=1.0
[basestring] => POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Faccess_token&oauth_consumer_key%3D**********(APIを叩くために指定したアプリのConsumer Key)%26oauth_nonce%3D0e5d6b7d94389876756828969162b08d%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1492424081%26oauth_token%3D4DsPdQAAAAAAe-QpAAABW3tn9zk%26oauth_verifier%3DqPsG9R7gRJAtqTFDsk8YVblHWgr1wzdJ%26oauth_version%3D1.0
[signing_key] =>**********(APIを叩くために指定したアプリのConsumer Secret)&KLrLAKuKB8WKC8CNBAH4j09cde0aXEac
)
)
「ツイートの一括削除ツール!」で言うと、「ツイッター認証」ボタンをクリックしてツイッター認証ページから元のページに戻って「※認証済み」が表示されるまでの流れがここまで。
なお、ここで取得できるユーザー認証情報「access_token」と「access_token_secret」は、アプリ開発ページの次の部分に該当する。

「access_token」と「access_token_secret」をデータベースなどに保存しておくと、いつでもこれを使ってそのユーザーのアカウントを操作できる。
これは継続的な操作を可能にする便利な機能でもあり、「勝手にスパムツイートをされる」というスパマーのターゲットにされる危険性もある(そのため怪しいツイッターアプリと連携するのは危険)。
なお、私は不用意にユーザーの大事な情報を保存したくないので一回ぽっきりでサーバーには保存していません。
あわせて読んでほしい!


1:yuta:2017/11/27 12:05:01
はじめまして。別の場所にコメントすべきなのですが、Tweetの一括削除ツールについて、以前はとてもお世話になっていたのに、最近はスパム認定されるのか削除できなくなってしまい、困っています。文字列指定ができて便利でした。なんとかしていただけないものでしょうか?