2015-12-08 67 views
0

嗨,我有一个计数器代码。 (例子)11结果时,我想停下来。当脚本计数11结果时,如何停止卷曲?如何设置柜台限制?

<?php 
class instaAuth 
{ 
    public function _userlistesi() { 
     $klasor = opendir("cookieboq/"); 
     while(false !== ($veriler = readdir($klasor))) { 
      if(strstr($veriler,'selco')) { 
      $bir_veri = str_replace('.selco','',$veriler); 
      $user_ekle .= "$bir_veri,"; 
     } 
    } 
    $userler = substr($user_ekle,0,-1); 
    $users_arr = explode(",",$userler); 
    return $users_arr; 
    } 

public function _authLike($_ID,$userlist, $DELETE = NULL) 
    { 
     if (!empty($userlist)) 
     { 
      $type = ($DELETE == TRUE) ? 'unlike' : 'like'; 

      $members = array(); 
      $params = array(); 
      foreach ($userlist as $username) 
      { 
       $_cookie = $this->_cookieFolder . $username . $this->_cookieExtension; 
       $randomProxy = (count($this->_proxy) > 0) ? $this->_proxy[rand(0, (count($this->_proxy) - 1))] : NULL; 

       if (!file_exists($_cookie)) 
       { 
        continue; 
       } 
       $members[] = $username; 
       $fake_ip = $this->fakeIP(); 
       $header = array(
        "Accept: */*", 
        "Accept-Language: tr;q=1", 
        "HTTP_CLIENT_IP"  => $fake_ip, 
        "HTTP_FORWARDED"  => $fake_ip, 
        "HTTP_PRAGMA"   => $fake_ip, 
        "HTTP_XONNECTION"  => $fake_ip,); 

       $options = array(
        CURLOPT_POST => TRUE, 
        CURLOPT_POSTFIELDS => $this->signed(json_encode(array())), 
        CURLOPT_HTTPHEADER => $header, 
        CURLOPT_COOKIEJAR => $_cookie, 
        CURLOPT_COOKIEFILE => $_cookie, 
        CURLOPT_USERAGENT => $this->_useragent, 
       ); 

       $params[] = array(
        'url' => "https://i.instagram.com/api/v1/media/{$_ID}/{$type}/", 
        'options' => $options 
       ); 
      } 
     } else { 
      throw new Exception('Error: _authLike() - Beğeni yaptırabilmeniz için {cookies} tanımlamalısınız.'); 
     } 
     $multiCURL = new \RollingCurl\RollingCurl(); 
     foreach ($params as $param) { 
      $request = new \RollingCurl\Request($param['url'], 'POST'); 
      $request->setOptions($param['options']); 
      $multiCURL->add($request); 
     } 

     $this->_result = 0; 
     $multiCURL 
      ->setCallback(function(\RollingCurl\Request $request, \RollingCurl\RollingCurl $rollingCurl) { 

       $result = $request->getResponseText(); 
       if (is_string($result)) 
       { 
        $result = json_decode($result); 
        if (is_object($result)) 
        { 
         if ($result->status == 'ok') $this->_result++; 
        } 
       } 
      }) 
      ->setSimultaneousLimit(100) 
      ->execute() 
     ; 

     $result = array(
      'success' => $this->_result, 
      'errors' => NULL 
     ); 

     return json_decode(json_encode($result)); 

    } 
} 

这insterested其他代码页

<form action="" method="POST"> 

Pictures ID : <input type="text" name="apifotoId"> 
<br> 
Limits : <input type="text" name="limit"> 
<br> 
<input type="submit" value="Like Send"> 
</form> 
<?php 
include("class.php") 
if(isset($_POST['apifotoId'])) { 
$start = time(); 
$y = new instaAuth(); 
$user_list = $y->_userlistesi(); 
$limit = $_POST["limit"]; 
$_ID = $_POST['apifotoId']; 
$y->_authLike($_ID,$user_list); 

$fark = round(time()-$start)/60; 
echo "Likes Complete (".$fark." dk.)"; 

} 

?> 

我想停下来的时候(例如)11结果。当脚本计数11结果时,如何停止卷曲?

+1

你想要计算的循环在哪里?这非常含糊。 –

回答

-1

只有在函数“authLike”条件if(result ==11) break; 和你,如果你清除你的答案,以帮助你更多,你可以使if语句。

+0

函数返回,所以我们发送所有数量的文件。但我们想限制这一点。 因此,我们编写11例,函数必须做11个结果,并停止 –

+0

skype:live:c3s3t add –