Wednesday, 15 May 2013

php - OAuth Issue for Pinger -



php - OAuth Issue for Pinger -

so here have, i'm trying create script php/curl login pinger textfree web service.

i have no thought i'm missing, i'm not seeing http transaction oauth. i've read bit i"m still lost.

any suggestions?

function sendrequest($url, $postorget, $fields = array(), $proxy) { $cookie_file = "cookies.txt"; //initiate connection $ch = curl_init(); curl_setopt($ch, curlopt_httpheader, $header); // set url //curl_setopt($ch, curlopt_header, false); curl_setopt($ch, curlopt_url, $url); // set url curl_setopt($ch, curlopt_returntransfer, 1); // homecoming transfer curl_setopt($ch, curlopt_ssl_verifypeer, false); // allow https curl_setopt($ch, curlopt_useragent, 'mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; .net clr 1.1.4322)'); // random agent curl_setopt($ch, curlopt_followlocation, 1); // automatically follow location: headers (ie redirects) curl_setopt($ch, curlopt_autoreferer, 1); // auto set referer in event of redirect curl_setopt($ch, curlopt_maxredirs, 5); // ibm likes redirect lot, create sure dont stuck in loop curl_setopt($ch, curlopt_cookiejar, $cookie_file); // file save cookies in curl_setopt($ch, curlopt_cookiefile, $cookie_file); // file read cookies curl_setopt($ch, curlopt_connecttimeout, 40); //timeout time curl //check see if proxy beingness used if(isset($proxy)){ //tell curl you're using proxy curl_setopt($ch, curlopt_proxytype, curlproxy_socks5); //set proxy curl_setopt($ch, curlopt_proxy, $proxy); } //check if request post or if ($postorget == "post" or $postorget == "post") { curl_setopt($ch, curlopt_post, true); // utilize post if (is_array($fields)){ curl_setopt($ch, curlopt_postfields, http_build_query($fields)); // key => name gets turned &key=name } else { curl_setopt($ch, curlopt_postfields, $fields); // &key=name passed in } } else { curl_setopt($ch, curlopt_post, false); // utilize } $content = curl_exec($ch); // homecoming html content $info = curl_getinfo($ch); // homecoming transfer info $error = curl_error($ch); // homecoming errors curl_close($ch); $request = array('content' => $content, 'error' => $error, 'info' => $info); homecoming $request; } //login details $username = "usernaem"; $password = "password"; //get initial login page $initfields = ""; $initoutput = sendrequest("http://www.pinger.com/tfw/?t=1360619019053", "get", $initfields); echo "<textarea cols='100' rows='400'>"; print_r($initoutput); echo "</textarea>"; //login pinger $loginfields = "{\"username\":\"".$username."\",\"password\":\"".$password."\",\"clientid\":\"textfree-in-flash-web-free-1360619009-8ca1c5c1-38ed-2e31-3248-cb367450a20f\"}"; $loginoutput = sendrequest("https://api.pinger.com/1.0/web/login", "post", $loginfields); echo "<textarea cols='100' rows='400'>"; print_r($loginoutput); echo "</textarea>";

we noticed section in script php/curl user names mentioned.

please check section of code:

//login details

$username = "usernaem"; $password = "password";

you notice section specifies username misspelled

usernaem

please seek correcting error , should prepare issue.

php curl oauth

No comments:

Post a Comment