Ejemplo n.º 1
0
    public function testUploadIfFilePartOfData()
    {
        $response = Unirest\Request::post('http://httpbin.org/post', array(
            'Accept' => 'application/json'
        ), array(
            'name' => 'Mark',
            'files[owl.gif]' => Unirest\File::add(UPLOAD_FIXTURE)
        ));
        $this->assertEquals(200, $response->code);

        //$files = $response->body->files;
        //$this->assertEquals('This is a test', $files->file);

        $form = $response->body->form;
        $this->assertEquals('Mark', $form->name);
    }
Ejemplo n.º 2
0
 public function testUploadIfFilePartOfData()
 {
     $response = Unirest\Request::post('http://mockbin.com/request', array('Accept' => 'application/json'), array('name' => 'Mark', 'files[owl.gif]' => Unirest\File::add(UPLOAD_FIXTURE)));
     $this->assertEquals(200, $response->code);
     $this->assertEquals('POST', $response->body->method);
     $this->assertEquals('Mark', $response->body->postData->params->name);
     $this->assertEquals('This is a test', $response->body->postData->params->{'files[owl.gif]'});
 }
Ejemplo n.º 3
0
 $profpic = $_POST['profpic'];
 $signature = $_POST['signature'];
 $account = array();
 // Getting server ip address
 $serverIP = gethostbyname(gethostname());
 // Getting target folder of the signature
 $targetPath = "signatures/";
 // Final file url that is being uploaded
 $fileUpload = '/Users/rimaraksa/Sites/android_connect' . '/' . $targetPath . $signature;
 // Change X-Mashape-Key, album, and album key
 $X_Mashape_Key = "yxgaLRvhf3msh8lKOCP4kiyng64Np1NlssnjsngXI6UmUTXXBN";
 $album = "Approve";
 $albumkey = "93047593e2f2fb8176be64548e998490f3ee24ec4ce7d091d7082eea18051c5d";
 $url = "https://lambda-face-recognition.p.mashape.com/album_train";
 // Train the album in Lambdal server
 $response = Unirest\Request::post($url, array("X-Mashape-Key" => $X_Mashape_Key), array("album" => $album, "albumkey" => $albumkey, "entryid" => $username, "files" => Unirest\File::add($fileUpload)));
 // Write the respose after training the album
 $file = fopen("log_album_train.txt", "w");
 fwrite($file, $response->raw_body);
 fclose($file);
 // URL for rebuilding an album
 $url = "https://lambda-face-recognition.p.mashape.com/album_rebuild?album=" . $album . "&albumkey=" . $albumkey;
 // Rebuild the album in Lambdal server
 $response = Unirest\Request::get($url, array("X-Mashape-Key" => $X_Mashape_Key, "Accept" => "application/json"));
 // Write the respose from rebuilding the album
 $file = fopen("log_album_rebuild.txt", "w");
 fwrite($file, $response->raw_body);
 fclose($file);
 // Prepare for returning the result to user
 // The file was not uploaded successfully to Lambal server
 if (!$response) {