Jump to content

AJAX and Twitter


stuffradio

Recommended Posts

Can anyone help me find out how to check if a twitter username/password is correct upon form submit. I have code to do that in PHP already, but if the user/pass combo is incorrect I want the form to stay where it is so the user can correct the info instead of reloading the page.

 

This is the code

function followUser()
   {
$apiUrl='http://twitter.com/friendships/create/'.$this->follower.'.xml';
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$apiUrl");
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_USERPWD, $this->username.':'.$this->password);
//Attempt to send
$buffer = curl_exec($curl_handle);
$resultArray = curl_getinfo($buffer);

if ($resultArray['http_code'] == 200):
return true;
else:
return false;
endif;
curl_close($curl_handle);

}   

 

Any help with this would be appreciated!

Link to comment
https://forums.phpfreaks.com/topic/153590-ajax-and-twitter/
Share on other sites

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.