Shoutbox

Problem with Twitter-PHP and My Script - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Problem with Twitter-PHP and My Script (/showthread.php?tid=92209)

Problem with Twitter-PHP and My Script by m0nst3rkill3r on 09-14-2009 at 06:58 PM

Hey.
First of all. Im a newbee^^
I wrote a Php script that checksout the xml of my account.
it saves the text in c:/twitter.txt
My Plus Script reads out this text, and set it to the Statusbar.
That works with /twitt
how can i "open" the phpfile with javascript ?

please help me

greetings

/edit:
Sure, its localhost/twitter.php ^^


RE: Problem with Twitter-PHP and My Script by matty on 09-14-2009 at 07:17 PM

-dt-'s reply to Tips


RE: Problem with Twitter-PHP and My Script by m0nst3rkill3r on 09-14-2009 at 07:42 PM

Okay Thank you for your Response!.
But i does not work, how i want it.
That's my Php.

code:
<?php
$datei = "C:/twitter.txt";

$xmltext = join(file("http://www.twitter.com/status/user_timeline/p3acemak3r.xml"), "");
$xmlobj = simplexml_load_string($xmltext);
print header("Content-type: text/plain");
//print_r ($xmlobj);
$twitt = $xmlobj->status->text;
print ($twitt);
$dat=fopen($datei,"w+");
fwrite($dat,$twitt);
fclose($dat);
?>



If i open it in my Browser, it works everything.
But if i use :

code:
xmlhttp.open("GET", "http://localhost/twitter/twitter.php", true);
xmlhttp.send('');


Nothing works.
RE: Problem with Twitter-PHP and My Script by matty on 09-14-2009 at 08:03 PM

Javascript code:
 getPageText ( 'http://www.twitter.com/status/user_timeline/p3acemak3r.xml' );
 
function getPageText ( url ) {
    var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
    xmlhttp.open('GET', url, true);
 
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) {
            Debug.Trace(xmlhttp.responseText);
        }
    }
    xmlhttp.send('');
}


Or you can use the URLDownloadToFileW:
Javascript code:
 getPageText ( 'http://www.twitter.com/status/user_timeline/p3acemak3r.xml' , 'C:\\twitter.txt' )
function getPageText ( url , file ) {
    return Interop.Call ( 'urlmon', 'URLDownloadToFileW', null, url, file, 0, 0 ) === 0
}


RE: Problem with Twitter-PHP and My Script by m0nst3rkill3r on 09-14-2009 at 08:11 PM

Yea.

But if you look in the Xml, you see there are many Categorys.
I dont see a Point in the Script where the "Position" is defined.


RE: RE: Problem with Twitter-PHP and My Script by matty on 09-15-2009 at 12:46 PM

quote:
Originally posted by m0nst3rkill3r
Yea.

But if you look in the Xml, you see there are many Categorys.
I dont see a Point in the Script where the "Position" is defined.


You would have had to figure that one out for yourself...

Javascript code:
getTwitterStatusFromXML ( 'http://www.twitter.com/status/user_timeline/p3acemak3r.xml' );
   
function getTwitterStatusFromXML ( url )
{
    var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
    var xml = new ActiveXObject('Microsoft.XMLDOM');
    xmldom.async = true;
    xmlhttp.open('GET', url, true);
 
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState === 4 && xmlhttp.status === 200 )
        {
            xmldom.loadXML ( xmlhttp.responseText );
            Debug.Trace (  xmldom.documentElement.selectSingleNode ( '//statuses/status/text' ).text );
        }
    }
    xmlhttp.send();
}


RE: Problem with Twitter-PHP and My Script by m0nst3rkill3r on 09-15-2009 at 02:39 PM

Ahw. Thank you!.
I want to do it myself, but i was disconnected  from msn, after i spammed my Contact to the death with my sript :D.
Anyway. Thank you for your help.


RE: Problem with Twitter-PHP and My Script by matty on 09-15-2009 at 02:42 PM

I wrote it without even being connected to WLM. I am at work. I wrote it as a HTML file but I had to use the https version of the page as the unsecure is blocked by my work web filter.


RE: Problem with Twitter-PHP and My Script by m0nst3rkill3r on 09-15-2009 at 03:07 PM

Fehler: 'xmldom' is undefined (Code: -2146823279)
       Datei: I Love Twitter.js. Zeile: 42.
Skriptstart fehlgeschlagen

I get with your code.
The Problem is, i Can code php and html use css and so on. But javascript i did not learn. :( I think, that's my new langauge i will learn.


RE: Problem with Twitter-PHP and My Script by matty on 09-15-2009 at 03:10 PM

Change this:

Javascript code:
var xml = new ActiveXObject('Microsoft.XMLDOM');

to this:
Javascript code:
var xmldom = new ActiveXObject('Microsoft.XMLDOM');


My bad!

This is more JScript than Javascript.
RE: Problem with Twitter-PHP and My Script by m0nst3rkill3r on 09-15-2009 at 03:13 PM

Fehler: 'xmldom.documentElement' is null or not an object (Code: -2146823281)
       Datei: I Love Twitter.js. Zeile: 50.

it's very embrassing to ask that.
Its so Easy. but i dont get it :(


RE: Problem with Twitter-PHP and My Script by matty on 09-15-2009 at 06:40 PM

I am now contemplating my code.

You can try removing the documentElement piece from the code and try. Therefore the code would look like this:

Javascript code:
            Debug.Trace (  xmldom.selectSingleNode ( '//statuses/status/text' ).text );

instead of this:
Javascript code:
            Debug.Trace (  xmldom.documentElement.selectSingleNode ( '//statuses/status/text' ).text );


RE: Problem with Twitter-PHP and My Script by m0nst3rkill3r on 09-18-2009 at 11:48 AM

You are Wonderful!
Thank you much!


RE: Problem with Twitter-PHP and My Script by matty on 09-18-2009 at 01:01 PM

Glad it worked. If you wanted to loop through all of the status in the XML file you could do something like this:

Javascript code:
getTwitterStatusFromXML ( 'http://www.twitter.com/status/user_timeline/p3acemak3r.xml' );
   
function getTwitterStatusFromXML ( url )
{
    var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
    var xmldom = new ActiveXObject('Microsoft.XMLDOM');
    xmldom.async = true;
    xmlhttp.open('GET', url, true);
 
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState === 4 && xmlhttp.status === 200 )
        {
            xmldom.loadXML ( xmlhttp.responseText );
            var oXmlArray = xmldom.selectNodes ( '//statuses/status/text' );
            for ( var i=0; i<oXmlArray.length; ++i )
            {
                Debug.Trace ( oXmlArray[i].text );
            }
        }
    }
    xmlhttp.send();
}


RE: Problem with Twitter-PHP and My Script by m0nst3rkill3r on 09-18-2009 at 02:31 PM

No, i just need the first post.
anyway, thank you.. again :D