Im trying to log into Yammer using cURL. For some reason I cant get the site to accept the password. You can try by going to this URL https://www.yammer.com/login?login=username%40domain.com&password=password. Is there something I am doing wrong? The Username(login) shows up fine but the password wont..
EDIT:
Here is my code
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookie.txt");
curl_setopt($ch, CURLOPT_URL,"https://www.yammer.com/login");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "login=" . urlencode("user@domain.com") . "&password=" . urlencode("password"));
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30");
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
ob_start();
curl_exec ($ch);
ob_end_clean();
curl_close ($ch);
unset($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie.txt");
curl_setopt($ch, CURLOPT_URL,"https://www.yammer.com/");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30");
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
$buf2 = curl_exec ($ch);
curl_close ($ch);
echo $buf2;
?>
I had a look at the source for the Yammer login page:
As you can see, the login form has method set to “post”. The URL you’ve provided in the question will make an HTTP GET request. In order to simulate your browser when it logs in, you’ll need to tell Curl to make a POST request instead.
See this question for a few options that should work – you may also find the man page for Curl useful.
Edit: thanks for providing the extra info. I had another look at the page source and spotted what might be causing your problem – there’s another input in the form:
It looks like you’ll need to make another Curl request first to retrieve the value of that field, and then add it into the post fields that you are submitting.