Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Twitter API

  1. #11
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    Below is my user construct function, and it's grabbing the user details from a database. But when I go to update.php it says Username and/or password not set.

    I don't understand why it's doing this as the code is fine, any help? Thanks.

    PHP Code:
    include ("includes/global.php");

    $d mysql_query("SELECT * FROM twitter WHERE user = '$ouser'");
    $details mysql_fetch_array($d);

    $use $details['twituser'];
    $pw $details['twitpw'];

        function 
    __construct ($user$password
        {
            
    $this->Username "$use";
            
    $this->Password "$pw";
        } 

  2. #12
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    What the hell are you doing?

    You're not in a class, so why are you using __construct?

    Plus where is $user and $password set?

    Plus, in your construct, you're not even using $user and $password? And you're using $this outside of a class?

    Where the hell did you get these ideas?

  3. #13
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    I just took the code from the class, so it is in a class yes. I don't know where $user and $password are set, that's how it was when I downloaded it.

  4. #14
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    You took the code from the class.. if you did that.. it's no longer in the class?

    Just look at the example files on PHPClasses, the link I provided you.. it shows you exactly how to do it..

  5. #15
    Join Date
    Feb 2009
    Posts
    131
    Tokens
    0

    Default

    Quote Originally Posted by Awfy View Post
    Don't be a complete moron, of course people use Twitter. More people use it now than ever before.
    Was there a need to call me a moron? No.

    You are the moron.

    I just asked as it's not really been discussed about lately on here, or many people using "twitter.com/MAHNAME" as their MSN names anymore.

  6. #16
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    Quote Originally Posted by Dentafrice View Post
    You took the code from the class.. if you did that.. it's no longer in the class?

    Just look at the example files on PHPClasses, the link I provided you.. it shows you exactly how to do it..
    I copy and pasted the parts of the code from my_twitter.php and pasted it here to show you my problem. It is still in a class.

  7. #17
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Paste your whole file..

  8. #18
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    my_twitter.php:
    PHP Code:
    <?php
    include ("includes/global.php");

    $d mysql_query("SELECT * FROM twitter WHERE user = '$ouser'");
    $details mysql_fetch_array($d);

    $use $details['twituser'];
    $pw $details['twitpw'];

    class 
    twitter
    {
            
        private 
    $Username;
        private 
    $Password;
        
        
    //
        
    private $MaxLength 140;
        private 
    $UserTimeLine = array ();
        private 
    $FollowingTimeLine = array ();
        private 
    $Replies = array ();
        
        private 
    $UrlTwitter 'http://twitter.com/';
        private 
    $UrlStatus 'http://twitter.com/statuses/';
        
        function 
    __construct ($user$password
        {
            
    $this->Username "$use";
            
    $this->Password "$pw";
        }
                 
    /********************* Status Methods *****************************/

    //Update Status
        
    public function updateStatus ($status='')
        { 
            if(empty(
    $this->Username) || empty($this->Password))
            {
                
    $this->Error(1);
            } else 
            {
                if(!empty(
    $status) && strlen($status) <= $this->MaxLength)
                {
                    
    $url $this->UrlStatus;
                    
    $url .= 'update.xml?status='urlencode(stripslashes(urldecode($status)));
                    
                    
    $request $this->requestToTwitter($url);
                    return 
    $request;
                    
                }else
                {
                    
    $this->Error(3);
                }
            }
        }
    update.php:
    PHP Code:
    <?php    
    include ("includes/global.php");
    include (
    "my_twitter.php");

    $getstatus $_POST['status'];

    $twitter =  new twitter('TwitterUser''TwitterPassword');

    $twitter->updateStatus($getstatus);
            
    ?>

    <form method="POST">
    <input type="text" name="status" />
    <input type="submit" value="tweet" />
    </form>

  9. #19
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    Don't worry about it anymore, I figured it out.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •