致命错误:对第46行/xxxx/xxxxx/xxxx.php中的非对象调用成员函数post()

致命错误:对第46行/xxxx/xxxxx/xxxx.php中的非对象调用成员函数post(),php,mysql,twitter,Php,Mysql,Twitter,我有一个从数据库中获取密钥和机密列表的代码,结构如下所述。无论如何,当我尝试提交表单并使用列表获取收藏夹时,它会给出上面列出的错误(对非对象调用成员函数post()),我不确定原因。这是我的代码,看到错误了吗 <?php /** * @file * User has successfully authenticated with Twitter. Access tokens saved to session and DB. */ if(isset($_POST['submit']))

我有一个从数据库中获取密钥和机密列表的代码,结构如下所述。无论如何,当我尝试提交表单并使用列表获取收藏夹时,它会给出上面列出的错误(对非对象调用成员函数post()),我不确定原因。这是我的代码,看到错误了吗

<?php
/**
 * @file
 * User has successfully authenticated with Twitter. Access tokens saved to session and DB.
 */
if(isset($_POST['submit'])){
require_once('twitteroauth/twitteroauth.php');
$con=mysqli_connect("host","user","pass","twtid");
// Check connection
if (mysqli_connect_errno())
  {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$result = mysqli_query($con,"SELECT * FROM twitter");
$connection = array();
while($row = mysqli_fetch_array($result, MYSQL_ASSOC)){
    $connection[$row['id']] = new TwitterOAuth(key, secret, $row['key'], $row['secret']);
}


/* Create a TwitterOauth object with consumer/user tokens. */
/* $content = $access_token['oauth_token']. " " . $access_token['oauth_token_secret']; */
/* $content = $connection->get("account/verify_credentials"); */

$url1 = parse_url($_POST['url'], PHP_URL_PATH);
$url = explode("/", $url1);

 /* If method is set change API call made. Test is called by default. */
$method = 'statuses/retweet/'.$url[3];
$amt = rand(10,15);
$sub = rand(1,2);
$amt1 = $amt-$sub-1;
for ($x=0; $x<=$amt; $x++)
   {
    if($_POST['retweet'] == "Retweet"){
        $content = twitteroauth_row($method, $connection[$x]->post($method), $connection[$x]->http_code);
    }

    if($x == 9) {
        $done = "yes";
    }
}

for ($x1=0; $x1<=$amt1; $x1++)
   {
if($_POST['favorite'] == "Favourite"){
$content = $connection[$x1]->post('favorites/create', array('id' => $url[3]));  
}

   }
}

非常明显:
$connection[$x1]
对于$x1Mark的值不存在,它应该存在,因为在我的数据库中,id最多为18。取一个随机数10-15,它应该存在。仅仅因为它存在于数据库中,并不意味着
new Twitteroauth
调用实际上返回了一个有效的对象。您将为数组中的该插槽分配了一些内容,但错误消息非常清楚地表明它不是一个对象