Unirest\Request::setMashapeKey PHP Method

setMashapeKey() public static method

Note: Mashape provides 2 keys for each application: a 'Testing' and a 'Production' one. Be aware of which key you are using and do not share your Production key.
public static setMashapeKey ( string $key ) : string
$key string Mashape key
return string
    public static function setMashapeKey($key)
    {
        return self::defaultHeader('X-Mashape-Key', $key);
    }

Usage Example

Example #1
0
 public function testSetMashapeKey()
 {
     Request::setMashapeKey('abcd');
     $response = Request::get('http://mockbin.com/request');
     $this->assertEquals(200, $response->code);
     $this->assertTrue(property_exists($response->body->headers, 'x-mashape-key'));
     $this->assertEquals('abcd', $response->body->headers->{'x-mashape-key'});
     // send another request
     $response = Request::get('http://mockbin.com/request');
     $this->assertEquals(200, $response->code);
     $this->assertTrue(property_exists($response->body->headers, 'x-mashape-key'));
     $this->assertEquals('abcd', $response->body->headers->{'x-mashape-key'});
     Request::clearDefaultHeaders();
     $response = Request::get('http://mockbin.com/request');
     $this->assertEquals(200, $response->code);
     $this->assertFalse(property_exists($response->body->headers, 'x-mashape-key'));
 }