drqja5919276 2013-02-13 01:39
浏览 53

Pinger的OAuth问题

So here is what I currently have, I'm trying to make a script with PHP/cURL that will login to the Pinger TextFree Web service.

I have no idea what I'm missing, I'm not seeing the HTTP transaction for the OAuth. I've read a bit about it but 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); // return the 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 the referer in the event of a redirect
curl_setopt($ch, CURLOPT_MAXREDIRS, 5); // ibm likes to redirect a lot, make sure we dont get stuck in a loop
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); // file to save cookies in
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); // file to read cookies from
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 40); //timeout time for curl

//Check to see if a proxy is being used
if(isset($proxy)){
    //Tell cURL you're using a proxy
    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
    //Set the proxy
    curl_setopt($ch, CURLOPT_PROXY, $proxy); 
}

//Check if request is POST or GET
if ($postorget == "post" OR $postorget == "POST")
{
    curl_setopt($ch, CURLOPT_POST, true); // use POST
    if (is_array($fields)){
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields)); // key => name gets turned into &key=name
    } else {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); // &key=name passed in
    }
} else { 
    curl_setopt($ch, CURLOPT_POST, false); // use GET
}

$content = curl_exec($ch); // return html content
$info = curl_getinfo($ch); // return transfer info
$error = curl_error($ch);  // return any errors

curl_close($ch);

$request = array('content' => $content,
         'error' => $error,
     'info' => $info);

return $request;            
}
    //Login details
$username = "usernaem";
$password = "password";

//GET the 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 to 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>";
  • 写回答

1条回答 默认 最新

  • dongnuochen9449 2013-02-14 04:10
    关注

    We noticed this section in script with PHP/cURL where the user names are mentioned.

    Please check this section of the code:

        //Login details
    

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

    You will notice that the section that specifies username is misspelled

    usernaem

    Please try correcting this error and this should fix your issue.

    评论

报告相同问题?

悬赏问题

  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了