I have code which takes keys and secrets list from a database, the structure was described here. Anyways, when I try to submit the form and get favourites using the list, it gives me the error listed above (Call to a member function post() on a non-object) and I'm unsure why. Anyways here's my code, see any errors?
<?php
if(isset($_POST['submit'])){
require_once('twitteroauth/twitteroauth.php');
$amt = rand(10,18);
$sub = rand(1,2);
$amt1 = $amt-$sub-1;
$con=mysqli_connect("crowngaming.ipagemysql.com","twitter","Hipporules2?","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)) {
$iden = $row['id'];
$connection[$iden] = new TwitterOAuth('ZG808c0pad0ar7wpgYPmA', 'BWHnOag1aWQtoYRBH5OtsI9m9Ghr3pTuMBo6z4ZNNP8', $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];
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 ($y=0; $y<=$amt1; $y++)
{
if($_POST['favorite'] == "Favourite"){
$content = $connection[$y]->post('favorites/create', array('id' => $url[3]));
}
}
}