/**
  * Create OK OAuth response instance
  * @param string $string response data
  * @return Error|stdClass response instance
  */
 public static function createResponse($string)
 {
     $Object = json_decode($string);
     if (isset($Object->error_code)) {
         return Error::initializeByObject($Object);
     } else {
         return $Object;
     }
 }
예제 #2
0
 public function test()
 {
     $Object1 = new stdClass();
     $Object1->error_code = Error::CODE_ACTION_BLOCKED;
     $Object1->error_msg = 'Some error message';
     $Object1->error_data = 'data';
     $Error1 = Error::initializeByObject($Object1);
     $this->assertEquals(Error::CODE_ACTION_BLOCKED, $Error1->getCode());
     $this->assertFalse($Error1->isSessionExpired());
     $this->assertEquals('Some error message', $Error1->getMessage());
     $this->assertEquals('data', $Error1->getData());
     $Object2 = new stdClass();
     $Object2->error_code = Error::CODE_PARAM_SESSION_EXPIRED;
     $Object2->error_msg = 'Some error message';
     $Object2->error_data = 'data';
     $Error2 = Error::initializeByObject($Object2);
     $this->assertEquals(Error::CODE_PARAM_SESSION_EXPIRED, $Error2->getCode());
     $this->assertTrue($Error2->isSessionExpired());
     $this->assertEquals('Some error message', $Error2->getMessage());
     $this->assertEquals('data', $Error2->getData());
 }