Jump to content

Xbox Live Twitter status update


Appzmaster

Recommended Posts

I have a script that updates a users status on twitter based on their xbox live info it works all great but I need to implement something that will allow it to only update users status if their xbox live status is online else it just spams the account away. I am pretty new to using arrays and what not so I am not really sure where to start with having it check that condition and if they are offline it would just skip to the next user in the database and not run the update on their account.

Link to comment
https://forums.phpfreaks.com/topic/170254-xbox-live-twitter-status-update/
Share on other sites

Well here is what actually updates the twitter status it connects to the db further up and uses a while to run this stuff

 

require("config/config.php");
require("config/opendb.php");
require ("Twitter.class.php");

    //Grab content from MySQL

$data = mysql_query("SELECT * FROM users") or die(mysql_error());


// keeps getting the next row until there are no more to get

while($row = mysql_fetch_array( $data )) {

// check whether get variables are existing and read xml file
if (file_exists($path.$file)) {

	$xml = simplexml_load_file($path.$file);


	$xbltweet2 = $xml->Gamertag;
	$xbltweet = $xml->PresenceInfo->Info;
	$xbltweet1 = $xml->PresenceInfo->Info2;

	//if ($xml->PresenceInfo->Online == false){

	//Some Code Once I figure It Out

	//}else{


//data to get
$tuser = $row[twitteruser];
$tpassword = $row[twitterpass];

//echo $tuser


$tweet = new Twitter("$tuser", "$tpassword");
// Set a new status. This can be called multiple times on the same object.
// The update() function returns true if the status update was successful or
// false if an error occured. In case of an error, a string describing the error
// is stored in the error variable of the object (in our case $tweet->error)
$success = $tweet->update("$xbltweet2 : $xbltweet : $xbltweet1");
if ($success) echo "Tweet successful!";
echo $tweet->error;

  }
}

You've not exactly given the clearest of explanations to be fair. Try this:

 

<?php

require("config/config.php");
require("config/opendb.php");
require ("Twitter.class.php");

//Grab content from MySQL
$data = mysql_query("SELECT * FROM users") or die(mysql_error());

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $data )) {

    // check whether get variables are existing and read xml file
    if (file_exists($path.$file)) {

        $xml = simplexml_load_file($path.$file);
      
        $xbltweet2 = $xml->Gamertag;
        $xbltweet = $xml->PresenceInfo->Info;
        $xbltweet1 = $xml->PresenceInfo->Info2;
      
        if ($xml->PresenceInfo->Online == true){
            //data to get
            $tuser = $row[twitteruser];
            $tpassword = $row[twitterpass];

            //echo $tuser

            $tweet = new Twitter("$tuser", "$tpassword");
            // Set a new status. This can be called multiple times on the same object.
            // The update() function returns true if the status update was successful or
            // false if an error occured. In case of an error, a string describing the error
            // is stored in the error variable of the object (in our case $tweet->error)
            $success = $tweet->update("$xbltweet2 : $xbltweet : $xbltweet1");
            if ($success) echo "Tweet successful!";
            echo $tweet->error;
        }
    }
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.