コード例 #1
0
function updateItem($itemId)
{
    global $accessToken, $connectHost, $requestHeaders;
    $request_body = array("name" => "Malted Milkshake");
    $response = Unirest\Request::put($connectHost . '/v1/me/items/' . $itemId, $requestHeaders, json_encode($request_body));
    if ($response->code == 200) {
        error_log('Successfully updated item:');
        error_log(json_encode($response->body, JSON_PRETTY_PRINT));
        return $response->body;
    } else {
        error_log('Item update failed');
        return NULL;
    }
}
コード例 #2
0
 public function testPut()
 {
     $response = Unirest\Request::put('http://mockbin.com/request', array('Accept' => 'application/json'), array('name' => 'Mark', 'nick' => 'thefosk'));
     $this->assertEquals(200, $response->code);
     $this->assertEquals('PUT', $response->body->method);
     $this->assertEquals('Mark', $response->body->postData->params->name);
     $this->assertEquals('thefosk', $response->body->postData->params->nick);
 }
コード例 #3
0
ファイル: RequestTest.php プロジェクト: pombredanne/ArcherSys
    public function testPut()
    {
        $response = Unirest\Request::put('http://httpbin.org/put', array(
            'Accept' => 'application/json'
        ), array(
            'name' => 'Mark',
            'nick' => 'thefosk'
        ));

        $this->assertEquals(200, $response->code);

        $form = $response->body->form;
        $this->assertEquals('Mark', $form->name);
        $this->assertEquals('thefosk', $form->nick);
    }