第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

無法使用 Twitter V1.1 API 驗(yàn)證用戶身份

無法使用 Twitter V1.1 API 驗(yàn)證用戶身份

PHP
慕斯王 2023-10-22 21:30:11
我已經(jīng)通過創(chuàng)建簽名實(shí)現(xiàn)了一切。我創(chuàng)建了一個(gè)函數(shù)來收集所需的參數(shù)(為了清楚起見,我在此處添加了一些注釋):function collect_parameters(){    global $credentials; // This is an Object with my App's credentials and stuff    $oAuth = get_user_oauth();  // This returns an object with the the personal user OAuth tokens retrieved from the earlier docs.    $encoded_collection = array();    $collection = array(        'status'                 => rawurlencode( $_GET['tweet'] ),        'include_entities'       => 'true',        'oauth_consumer_key'     => $credentials->key,        'oauth_nonce'            => $credentials->nonce, // md5( str_shuffle( uniqid() . mt_rand(0,9999999999) ) )        'oauth_signature_method' => 'HMAC-SHA1',        'oauth_timestamp'        => $credentials->time, // current timestamp        'oauth_token'            => $oAuth->oauth_token,        'oauth_version'          => '1.0',    );    // Percent encode every key and value that will be signed.    foreach( $collection as $key => $value ){        $encoded_collection[rawurlencode($key)] = rawurlencode($value);     }    // Sort the list of parameters alphabetically by encoded key.    ksort( $encoded_collection );    return http_build_query( $encoded_collection );}我使用這個(gè)函數(shù)來構(gòu)建簽名基字符串function create_signature_base_string( $parameter_string, $url = 'https://api.twitter.com/1.1/statuses/update.json', $method = 'POST' ){    return strtoupper( $method ) .'&'. rawurlencode( $url ) .'&'. rawurlencode( $parameter_string );}我用這個(gè)函數(shù)來計(jì)算簽名function calculate_signature( $signature_base_string, $signing_key ){    return base64_encode( hash_hmac('sha1', $signature_base_string, $signing_key, true) );}現(xiàn)在構(gòu)建 OAuth 標(biāo)頭。這是一個(gè)函數(shù),它使用上面的輔助函數(shù)(加上其他一些返回所需信息的函數(shù)):function get_oauth_headers(){    global $credentials;    $oAuth = get_user_oauth();        $parameters = collect_parameters();    $signature_base_string = create_signature_base_string( $parameters );    $signing_key = get_signing_key();    $signature = calculate_signature( $signature_base_string, $signing_key );    );
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關(guān)注
  • 152 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)