View Full Version : Twitter API
wsg14
16-02-2009, 03:43 PM
Where's the best place to learn the twitter API other than the actual twitter API wiki? Thanks.
Jaysun
16-02-2009, 04:31 PM
http://www.webmonkey.com/tutorial/Get_Started_With_the_Twitter_API
I think that should help.
RichardKnox
16-02-2009, 09:12 PM
The twitter API is actually really simple to use. IMO the API wiki is without a doubt the best place to learn it, but if you don't want to use that I'd suggest using Jaysuns link, even though I believe the wiki will tell you everything you need to know.
Dentafrice
16-02-2009, 10:47 PM
The wiki is going to tell you everything you need to know, and it is updated and changed so much, that's the best place to learn if you want the most up to date and accurate information on the correct methods and procedures to use.
wsg14
17-02-2009, 02:37 AM
My main problem is I don't know how to convert what it's saying into PHP.
Calgon
17-02-2009, 05:51 AM
Sorry to go off-topic, but does anybody actually use twitter anymore? lol.
And, I imagine the twitter website would be the best place..
Dentafrice
17-02-2009, 12:21 PM
My main problem is I don't know how to convert what it's saying into PHP.
http://apiwiki.twitter.com/Libraries#PHP
Sorry to go off-topic, but does anybody actually use twitter anymore? lol.
And, I imagine the twitter website would be the best place..
Yeah, of course they use it.. tons.
wsg14
20-02-2009, 01:56 AM
I've looked at those, they don't really say what they're doing. They just give you code. You've worked with the twitter API before, no? Mind giving me an example PHP code to post to Twitter?
Dentafrice
20-02-2009, 02:14 AM
All those have examples.
http://www.phpclasses.org/browse/file/20199.html
That's the MyTwitter library.. that's not just giving you code.. that's giving you tons of examples.
If you can't read through the API docs, and at least try to understand it, then there's no use in you trying yet, until you build up your skills.. because it is really relatively easy.
You're just sending POST requests to the server that are authenticated.
Just read through the doc, and you should be able to understand it..
Sorry to go off-topic, but does anybody actually use twitter anymore? lol.
And, I imagine the twitter website would be the best place..
Don't be a complete moron, of course people use Twitter. More people use it now than ever before.
wsg14
21-02-2009, 12:47 AM
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.
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";
}
Dentafrice
21-02-2009, 02:16 PM
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?
wsg14
21-02-2009, 02:55 PM
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.
Dentafrice
21-02-2009, 03:00 PM
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..
Calgon
21-02-2009, 03:04 PM
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.
wsg14
21-02-2009, 03:24 PM
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.
Dentafrice
21-02-2009, 03:37 PM
Paste your whole file..
wsg14
21-02-2009, 03:44 PM
my_twitter.php:
<?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
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>
wsg14
21-02-2009, 06:29 PM
Don't worry about it anymore, I figured it out.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.