使用CodeBird PHP的用户凭据验证错误和更新与媒体错误

时间:2013-08-28 03:15:06

标签: php twitter oauth twitter-oauth

我希望在用户登录表单后检查用户凭据,如果用户名和密码正确,用户将重定向到upload.php页面,上传图像和状态后,图像和状态将在用户twit上发布< / p>

这是我的verifikasi.php代码

<h2>Verifikasi ID Twitter...</h2>
/*verification of user credentials
after validation of username and password success, redirect to upload image and status page
but if validation of username and password fail, back to login page
*/

<?php

require_once('codebird.php');
$cb = new \Codebird\Codebird;

$id = $_POST['id'];
$pass = $_POST['pass'];

 //if($_POST['loginTwitter'] == "Submit"){
 //if(isset($_POST['loginTwitter'])){
 if(isset($id) && isset($pass)){
    //cek bener apa engga nya

    //if($_POST['id'] == '' || $_POST['pass'] == ''){ header('login.php'); }

    $cb::setConsumerKey('somekey', 'somekeysecret');
    $cb::getInstance();
    $cb->setToken('tokenaccess', 'tokenaccesssecret');

    $code = $cb->account_verifyCredentials();
    if($code == 200){ 
        //$reply = $cb->oauth2_token();
        //$bearer_token = $reply->access_token;
        header('upload.php');
    }
    else{ header('login.php'); }

  //echo "Redirect to Upload Image...."; for($i = 0; $i <= 20000000; $i++); header('upload.php');
 }

 else{
    echo "<br />";
    echo "<h3>Something went wrong... Please Check Again Your Credentials</h3>";
  }

?>

这里是post.php页面(使用update_with_media API将图像和状态发布到用户twit

<div id="photo_tweet">
<h2>Photo Tweet</h2>
<br />

<?php require_once('codebird.php'); ?>

<?php
  function redirectToUpload(){
    echo "Redirect...";
    for($i = 0; $i <= 20000000; $i++);
    header('upload.php');
  }
?>

<?php
$imgExt = array("jpeg", "jpg", "png");
$currImgExt = end( explode(".", $_FILES["file"]["name"]) );

if($_POST['uploadTwit'] == "Submit"){

 if ((($_FILES["file"]["type"] == "image/jpeg")
    || ($_FILES["file"]["type"] == "image/jpg")
    || ($_FILES["file"]["type"] == "image/pjpeg")
    || ($_FILES["file"]["type"] == "image/x-png")
    || ($_FILES["file"]["type"] == "image/png") || $_POST['status'] == '')
    && ($_FILES["file"]["size"] < 20000)
    && in_array($currImgExt, $imgExt))
 {
    if ($_FILES["file"]["error"] > 0){
        echo "Error: " . $_FILES["file"]["error"] . "<br>";
        redirectToUpload();
    }
    else{
          $params = array(
            'status' => $_POST['status'],
            'media[]' => $_FILES["file"]["name"]
          );

          /*
          $data_user = array(
            'user_id' => ,
            'screen_name' => 
          );
          */
       $reply = $cb->statuses_updateWithMedia($params);
    }
  }
 }
 else { echo "Invalid Image File or Invalid File Size or Twit cannot empty! Please check agian your image file before proceed!"; redirectToUpload(); }
?>

<p>You Just Succeed Post image and status!</p>

</div>

verifikasi.php的问题是 注意:第36行的C:\ wamp \ www \ twcodebird \ verifikasi.php中无法将类stdClass的对象转换为int

我想在verifikasi.php中返回状态代码,如果code = 200则用户重定向到upload.php页面, 但从错误回归看,似乎我的代码错误返回......我该怎么办?

对于post.php我还没有运行它,因为我想确保首先验证用户凭据

0 个答案:

没有答案