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
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;

  }
}

Link to comment
Share on other sites

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;
        }
    }
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.