Twitter登录时使用php错误400错误请求并在浏览器中{quot;code";:215,“message";:“错误身份验证数据”。}

Twitter登录时使用php错误400错误请求并在浏览器中{quot;code";:215,“message";:“错误身份验证数据”。},php,twitter,auth0,Php,Twitter,Auth0,我对twitterapi:v1.0有问题。正在尝试使用php代码创建签名 <?php $oauth_consumer_key = "API_KEY"; $oauth_nonce = generateRandomString(); $oauth_signature = ""; $oauth_signature_method = "HMAC-SHA1"; $oauth_timestamp = t

我对twitterapi:v1.0有问题。正在尝试使用php代码创建签名

<?php
    $oauth_consumer_key = "API_KEY";
    $oauth_nonce = generateRandomString();
    $oauth_signature = "";
    $oauth_signature_method = "HMAC-SHA1";
    $oauth_timestamp = time();
    $oauth_token = "ACCESS_TOKEN";
    $oauth_version = "1.0";
    $include_entities = "true";
    $twitteruser = "user_name";


    $url = 'https://api.twitter.com/1.1/statuses/update.json?';
        $params = "screen_name=$twitteruser&include_entities=$include_entities&oauth_consumer_key=$oauth_consumer_key&oauth_nonce=$oauth_nonce&oauth_signature_method=$oauth_signature_method&oauth_timestamp=$oauth_timestamp&oauth_token=$oauth_token&oauth_version=$oauth_version";
        $signatureUrl = $url.$params;


    // use key 'http' even if you send the request to https://...
    $options = array(
        'http' => array(
            'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
            'method'  => 'GET'
        )
    );
    $context  = stream_context_create($options);
    $result = file_get_contents($signatureUrl, false, $context);
    if ($result === FALSE) { echo "error"; }

    var_dump($result);

    
    function generateRandomString($length = 32) {
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $charactersLength = strlen($characters);
        $randomString = '';
        for ($i = 0; $i < $length; $i++) {
            $randomString .= $characters[rand(0, $charactersLength - 1)];
        }
        return $randomString;
    }