/** * Test retrieval of the details of an event. */ public function testGetEvent() { $response = <<<XML <response> <cdbid>e642dc9e-4682-4846-ac61-97a9a0cd38a2</cdbid> <checkinConstraint> <periodType>WEEK</periodType> <periodVolume>1</periodVolume> </checkinConstraint> <gracePeriodMonths>0</gracePeriodMonths> <numberOfPoints>1</numberOfPoints> <ticketSalesConstraint> <periodConstraint> <periodType>ABSOLUTE</periodType> <periodVolume>1</periodVolume> </periodConstraint> <volume>0</volume> </ticketSalesConstraint> </response> XML; /* @var $oauth_client_stub PHPUnit_Framework_MockObject_MockObject|CultureFeed_OAuthClient */ $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $oauth_client_stub->expects($this->once())->method('consumerGetAsXml')->with($this->equalTo('uitpas/cultureevent/e642dc9e-4682-4846-ac61-97a9a0cd38a2'))->will($this->returnValue($response)); $cf = new CultureFeed($oauth_client_stub); $event = $cf->uitpas()->getEvent('e642dc9e-4682-4846-ac61-97a9a0cd38a2'); $this->assertInstanceOf('\\CultureFeed_Uitpas_Event_CultureEvent', $event); $this->assertSame('e642dc9e-4682-4846-ac61-97a9a0cd38a2', $event->cdbid); $this->assertSame(1, $event->numberOfPoints); }
public function testGetDistributionKeysForOrganizer() { $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $get_xml = file_get_contents(dirname(__FILE__) . '/data/distributionkey/get.xml'); $oauth_client_stub->expects($this->once())->method('consumerGetAsXML')->will($this->returnValue($get_xml)); $cf = new CultureFeed($oauth_client_stub); $data = $cf->uitpas()->getDistributionKeysForOrganizer(self::ORGANIZERCDBID); $this->assertInstanceOf('CultureFeed_ResultSet', $data); $this->assertContainsOnly('CultureFeed_Uitpas_DistributionKey', $data->objects); $this->assertCount(6, $data->objects); $this->assertEquals(6, $data->total); /* @var CultureFeed_Uitpas_DistributionKey $key */ $key = reset($data->objects); $this->assertEquals(35, $key->id); $this->assertEquals("School - Halve Dag - €1,50", $key->name); $this->assertInstanceOf('CultureFeed_Uitpas_CardSystem', $key->cardSystem); $this->assertEquals(1, $key->cardSystem->id); $this->assertEquals('HELA', $key->cardSystem->name); $key = next($data->objects); $this->assertEquals(36, $key->id); $this->assertEquals("School - hele dag €3", $key->name); $this->assertInstanceOf('CultureFeed_Uitpas_CardSystem', $key->cardSystem); $this->assertEquals(1, $key->cardSystem->id); $this->assertEquals('HELA', $key->cardSystem->name); }
/** * Test the update of an event. */ public function testUpdateEvent() { $event = new CultureFeed_Uitpas_Event_CultureEvent(); $event->cdbid = 'da4cf0be-b28b-4b1d-b66f-50adc5638594'; $event->organiserId = 'b101b61b-1d91-4216-908e-2c0ac16bc490'; $event->locationId = 'abd76139-5b0d-42b1-ba5b-a40172e27fba'; $distributionKey200 = new CultureFeed_Uitpas_DistributionKey(); $distributionKey200->id = '200'; $distributionKey200->name = 'Distribution key 200'; $distributionKey201 = new CultureFeed_Uitpas_DistributionKey(); $distributionKey201->id = '201'; $distributionKey201->name = 'Distribution key 201'; $response = <<<XML <?xml version="1.0" encoding="utf-8" ?> <response> <code>ACTION_SUCCEEDED</code> <message>De event gegevens werden aangepast.</message> </response> XML; /* @var $oauth_client_stub PHPUnit_Framework_MockObject_MockObject|CultureFeed_OAuthClient */ $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $oauth_client_stub->expects($this->once())->method('consumerPostAsXml')->with($this->equalTo('uitpas/cultureevent/update'), $this->equalTo(array('cdbid' => $event->cdbid, 'locationId' => $event->locationId, 'actorId' => $event->organiserId, 'distributionKey' => array($distributionKey200->id, $distributionKey201->id))))->will($this->returnValue($response)); $event->distributionKey = array($distributionKey200, $distributionKey201); $cf = new CultureFeed($oauth_client_stub); $response = $cf->uitpas()->updateEvent($event); $this->assertInstanceOf('\\CultureFeed_Uitpas_Response', $response); $this->assertEquals('ACTION_SUCCEEDED', $response->code); $this->assertEquals('De event gegevens werden aangepast.', $response->message); }
/** * @test */ public function testCancelTicketSaleById() { $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $ticketId = 1; $consumerKey = 'abc'; $data = array('balieConsumerKey' => $consumerKey); $oauth_client_stub->expects($this->once())->method('authenticatedPostAsXml')->with('uitpas/cultureevent/cancel/' . $ticketId, $data); $cf = new CultureFeed($oauth_client_stub); $cf->uitpas()->cancelTicketSaleById($ticketId, $consumerKey); }
public function testRegisterTicketSale() { $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $register_xml = file_get_contents(dirname(__FILE__) . '/data/events/register.xml'); $oauth_client_stub->expects($this->any())->method('authenticatedPostAsXml')->with("uitpas/cultureevent/" . self::CDBID . "/buy/" . self::UITPAS_NUMBER, array('balieConsumerKey' => self::CONSUMER_KEY_COUNTER))->will($this->returnValue($register_xml)); $cf = new CultureFeed($oauth_client_stub); $ticket_sale = $cf->uitpas()->registerTicketSale(self::UITPAS_NUMBER, self::CDBID, self::CONSUMER_KEY_COUNTER); $this->assertEquals(7, $ticket_sale->id); $this->assertEquals(1322825015, $ticket_sale->creationDate); $this->assertEquals(45.0, $ticket_sale->price); }
public function testGetAssociations() { $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $balie_consumer_key = 'e52efb7f-2eab-47a5-9cf3-9e7413ffd942'; $xml = file_get_contents(dirname(__FILE__) . '/data/associations/list.xml'); $oauth_client_stub->expects($this->once())->method('authenticatedGetAsXml')->with('uitpas/association/list', array('balieConsumerKey' => $balie_consumer_key))->will($this->returnValue($xml)); $cf = new CultureFeed($oauth_client_stub); $result = $cf->uitpas()->getAssociations($balie_consumer_key); $this->assertInstanceOf('CultureFeed_ResultSet', $result); $this->assertEquals(3, $result->total); $this->assertInternalType('array', $result->objects); $this->assertCount(3, $result->objects); $this->assertContainsOnly('CultureFeed_Uitpas_Association', $result->objects); /* @var CultureFeed_Uitpas_Association $association */ $association = reset($result->objects); $this->assertEquals(1, $association->id); $this->assertEquals('CJP', $association->name); $this->assertCount(1, $association->cardSystems); $cardSystem = reset($association->cardSystems); $this->assertInstanceOf('CultureFeed_Uitpas_CardSystem', $cardSystem); $this->assertEquals(6, $cardSystem->id); $this->assertEquals('Testsysteem Paspartoe', $cardSystem->name); $this->assertSame(TRUE, $association->permissionRead); $this->assertSame(TRUE, $association->permissionRegister); $this->assertSame(CultureFeed_Uitpas_EndDateCalculation::FREE, $association->enddateCalculation); $this->assertSame(1451602799, $association->enddateCalculationFreeDate); $association = next($result->objects); $this->assertEquals(2, $association->id); $this->assertEquals('Okra', $association->name); $this->assertCount(1, $association->cardSystems); $cardSystem = reset($association->cardSystems); $this->assertInstanceOf('CultureFeed_Uitpas_CardSystem', $cardSystem); $this->assertEquals(1, $cardSystem->id); $this->assertEquals('HELA', $cardSystem->name); $this->assertSame(FALSE, $association->permissionRead); $this->assertSame(FALSE, $association->permissionRegister); $this->assertSame(CultureFeed_Uitpas_EndDateCalculation::BASED_ON_REGISTRATION_DATE, $association->enddateCalculation); $this->assertSame(1, $association->enddateCalculationValidityTime); $association = next($result->objects); $this->assertEquals(3, $association->id); $this->assertEquals('Foo', $association->name); $this->assertCount(1, $association->cardSystems); $cardSystem = reset($association->cardSystems); $this->assertInstanceOf('CultureFeed_Uitpas_CardSystem', $cardSystem); $this->assertEquals(1, $cardSystem->id); $this->assertEquals('HELA', $cardSystem->name); $this->assertSame(TRUE, $association->permissionRead); $this->assertSame(TRUE, $association->permissionRegister); $this->assertSame(CultureFeed_Uitpas_EndDateCalculation::BASED_ON_DATE_OF_BIRTH, $association->enddateCalculation); $this->assertSame(22, $association->enddateCalculationValidityTime); }
public function testGetCardCounts() { $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $xml = file_get_contents(dirname(__FILE__) . '/data/balie/countCards.xml'); $oauth_client_stub->expects($this->once())->method('authenticatedGetAsXml')->with('uitpas/balie/countCards')->will($this->returnValue($xml)); $cf = new CultureFeed($oauth_client_stub); $cardCounters = $cf->uitpas()->getCardCounters(); $this->assertInternalType('array', $cardCounters); $this->assertCount(4, $cardCounters); /** @var CultureFeed_Uitpas_Counter_CardCounter $cardCounter */ $cardCounter = reset($cardCounters); $this->assertInstanceOf('CultureFeed_Uitpas_CardSystem', $cardCounter->cardSystem); $this->assertEquals('HELA', $cardCounter->cardSystem->name); $this->assertEquals(1, $cardCounter->cardSystem->id); $this->assertFalse($cardCounter->kansenstatuut); $this->assertEquals('SENT_TO_BALIE', $cardCounter->status); $this->assertEquals(22, $cardCounter->count); $cardCounter = next($cardCounters); $this->assertInstanceOf('CultureFeed_Uitpas_CardSystem', $cardCounter->cardSystem); $this->assertEquals('HELA', $cardCounter->cardSystem->name); $this->assertEquals(1, $cardCounter->cardSystem->id); $this->assertTrue($cardCounter->kansenstatuut); $this->assertEquals('SENT_TO_BALIE', $cardCounter->status); $this->assertEquals(33, $cardCounter->count); $cardCounter = next($cardCounters); $this->assertInstanceOf('CultureFeed_Uitpas_CardSystem', $cardCounter->cardSystem); $this->assertEquals('HELA', $cardCounter->cardSystem->name); $this->assertEquals(1, $cardCounter->cardSystem->id); $this->assertFalse($cardCounter->kansenstatuut); $this->assertEquals('LOCAL_STOCK', $cardCounter->status); $this->assertEquals(3, $cardCounter->count); $cardCounter = next($cardCounters); $this->assertInstanceOf('CultureFeed_Uitpas_CardSystem', $cardCounter->cardSystem); $this->assertEquals('HELA', $cardCounter->cardSystem->name); $this->assertEquals(1, $cardCounter->cardSystem->id); $this->assertTrue($cardCounter->kansenstatuut); $this->assertEquals('LOCAL_STOCK', $cardCounter->status); $this->assertEquals(4, $cardCounter->count); }
/** * Test the searching events. */ public function testSearchEvents() { $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $get_xml = file_get_contents(dirname(__FILE__) . '/data/events/searchresults.xml'); $oauth_client_stub->expects($this->once())->method('consumerGetAsXML')->will($this->returnValue($get_xml)); $cf = new CultureFeed($oauth_client_stub); $query = new CultureFeed_Uitpas_Event_Query_SearchEventsOptions(); $data = $cf->uitpas()->searchEvents($query); $this->assertContainsOnly('CultureFeed_Uitpas_Event_CultureEvent', $data->objects); $this->assertCount(7, $data->objects); $this->assertEquals("8ea1787b-d08c-4fa8-8d3c-20d1e5cc6e6a", $data->objects[2]->cdbid); /* @var CultureFeed_Uitpas_Event_CultureEvent[] $events */ $events = $data->objects; $this->assertCount(2, $events[1]->ticketSales); $this->assertCount(1, $events[2]->ticketSales); // TicketSale 1 of 2nd event. (Coupon) $this->assertInstanceOf('CultureFeed_Uitpas_Event_TicketSale_Opportunity', $events[1]->ticketSales[0]); $this->assertEquals(CultureFeed_Uitpas_Event_TicketSale_Opportunity::TYPE_COUPON, $events[1]->ticketSales[0]->type); $this->assertInstanceOf('CultureFeed_Uitpas_Event_TicketSale_Coupon', $events[1]->ticketSales[0]->ticketSaleCoupon); $this->assertEquals(18, $events[1]->ticketSales[0]->ticketSaleCoupon->id); $this->assertEquals('TEST-UITPAS1579', $events[1]->ticketSales[0]->ticketSaleCoupon->name); $this->assertPeriodConstraint($events[1]->ticketSales[0]->ticketSaleCoupon->buyConstraint, CultureFeed_Uitpas_PeriodConstraint::TYPE_ABSOLUTE, 6); $this->assertPeriodConstraint($events[1]->ticketSales[0]->ticketSaleCoupon->exchangeConstraint, CultureFeed_Uitpas_PeriodConstraint::TYPE_MONTH, 3); $this->assertPeriodConstraint($events[1]->ticketSales[0]->remainingForEvent, CultureFeed_Uitpas_PeriodConstraint::TYPE_WEEK, 10); $this->assertPeriodConstraint($events[1]->ticketSales[0]->remainingTotal, CultureFeed_Uitpas_PeriodConstraint::TYPE_QUARTER, 50); $this->assertPriceClass($events[1]->ticketSales[0]->priceClasses[0], 'Default prijsklasse', 27.0, 13.5); // TicketSale 2 of 2nd event. (Kansentarief with buyConstraintReason.) $this->assertInstanceOf('CultureFeed_Uitpas_Event_TicketSale_Opportunity', $events[1]->ticketSales[1]); $this->assertEquals(CultureFeed_Uitpas_Event_TicketSale_Opportunity::TYPE_DEFAULT, $events[1]->ticketSales[1]->type); $this->assertEquals(CultureFeed_Uitpas_Event_TicketSale_Opportunity::BUY_CONSTRAINT_INVALID_DATE_CONSTRAINTS, $events[1]->ticketSales[1]->buyConstraintReason); // TicketSale 1 of 3rd event. (Kansentarief) $this->assertInstanceOf('CultureFeed_Uitpas_Event_TicketSale_Opportunity', $events[2]->ticketSales[0]); $this->assertEquals(CultureFeed_Uitpas_Event_TicketSale_Opportunity::TYPE_DEFAULT, $events[2]->ticketSales[0]->type); $this->assertCount(3, $events[2]->ticketSales[0]->priceClasses); $this->assertPriceClass($events[2]->ticketSales[0]->priceClasses[0], 'Rang 1', 28.0, 21.0); $this->assertPriceClass($events[2]->ticketSales[0]->priceClasses[1], 'Rang 2', 21.0, 14.0); $this->assertPriceClass($events[2]->ticketSales[0]->priceClasses[2], 'Rang 3+', 14.0, 7.0); }
/** * Test the registering of an event. */ public function testRegisterEvent() { $response = <<<XML <?xml version="1.0" encoding="utf-8" ?> <response> <code>1</code> <message>foo</message> </response> XML; /* @var $oauth_client_stub PHPUnit_Framework_MockObject_MockObject */ $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $oauth_client_stub->expects($this->once())->method('consumerPostAsXml')->with($this->equalTo('uitpas/cultureevent/register'))->will($this->returnValue($response)); $event_xml_str = file_get_contents(dirname(__FILE__) . self::EVENTXML); $event_xml_obj = new CultureFeed_SimpleXMLElement($event_xml_str); $event = CultureFeed_Uitpas_Event_CultureEvent::createFromXML($event_xml_obj); $this->assertInstanceOf('CultureFeed_Uitpas_Event_CultureEvent', $event); $this->assertEquals("9ba1b072-40ea-41b6-a66b-ac3fdf646f36", $event->cdbid); $this->assertEquals("5C9C73D3-E82F-E7B3-44161E6E3802E64F", $event->locationId); $cf = new CultureFeed($oauth_client_stub); $response = $cf->uitpas()->registerEvent($event); $this->assertInstanceOf('\\CultureFeed_Uitpas_Response', $response); $this->assertEquals(1, $response->code); $this->assertEquals('foo', $response->message); }
require_once dirname(__FILE__) . '/../../OAuth/OAuth.php'; function culturefeed_autoload($class) { $file = str_replace('_', '/', $class) . '.php'; require_once $file; } spl_autoload_register('culturefeed_autoload'); try { $endpoint = $_SERVER['argv'][1]; $consumer_key = $_SERVER['argv'][2]; $consumer_secret = $_SERVER['argv'][3]; $uitpas_number = $_SERVER['argv'][4]; $auth_callback_url = 'http://example.com'; $date_of_birth = DateTime::createFromFormat('Y-m-d', $_SERVER['argv'][5]); $oc = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret); $oc->setEndpoint($endpoint); $c = new CultureFeed($oc); $link = $c->uitpas()->getPassholderActivationLinkChainedWithAuthorization($uitpas_number, $date_of_birth, $auth_callback_url); print $link . PHP_EOL; } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1); }
date_default_timezone_set('Europe/Brussels'); // require the third-party oauth library which is not properly structured to be autoloaded require_once dirname(__FILE__) . '/../../OAuth/OAuth.php'; function culturefeed_autoload($class) { $file = str_replace('_', '/', $class) . '.php'; require_once $file; } spl_autoload_register('culturefeed_autoload'); try { $endpoint = $_SERVER['argv'][1]; $consumer_key = $_SERVER['argv'][2]; $consumer_secret = $_SERVER['argv'][3]; $query = new CultureFeed_Uitpas_Passholder_Query_SearchPromotionPointsOptions(); $oc = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret); $oc->setEndpoint($endpoint); $c = new CultureFeed($oc); $promotions = $c->uitpas()->getPromotionPoints($query); print_r($promotions); } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1); }
public function testSearchCheckins() { $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $checkins_xml = file_get_contents(dirname(__FILE__) . '/data/cultureevent/searchCheckins.xml'); $oauth_client_stub->expects($this->any())->method('consumerGetAsXml')->will($this->returnValue($checkins_xml)); $cf = new CultureFeed($oauth_client_stub); $query = new CultureFeed_Uitpas_Event_Query_SearchCheckinsOptions(); $checkins = $cf->uitpas()->searchCheckins($query, NULL, CultureFeed_Uitpas::CONSUMER_REQUEST); $this->assertEquals(12, $checkins->total); $this->assertInternalType('array', $checkins->objects); $this->assertContainsOnly('CultureFeed_Uitpas_Event_CheckinActivity', $checkins->objects, FALSE); /** @var CultureFeed_Uitpas_Event_CheckinActivity $checkin */ $checkin = reset($checkins->objects); $this->assertEquals(12, $checkin->type); $this->assertEquals('event', $checkin->contentType); $this->assertEquals('CC De Werf', $checkin->createdVia); $this->assertEquals(1384267680, $checkin->creationDate); $this->assertEquals('http://media.uitid.be/fis/rest/download/ce126667652776f0e9e55160f12f5478/uiv/default.png', $checkin->depiction); $this->assertEquals('76faa534-4c3e-4f2e-abe5-10bd0a2e5e14', $checkin->id); $this->assertEquals('Frontend Tester', $checkin->nick); $this->assertEquals('c44d849a-1290-4927-81ac-e782428de887', $checkin->nodeId); $this->assertEquals('test cine palace', $checkin->nodeTitle); $this->assertEquals(0, $checkin->points); $this->assertInternalType('boolean', $checkin->private); $this->assertEquals(FALSE, $checkin->private); $this->assertEquals('a81b1741-5e97-4eee-ab30-a71865fc266a', $checkin->userId); $this->assertEquals('Frontend', $checkin->firstName); $this->assertEquals('FEMALE', $checkin->gender); $this->assertInternalType('boolean', $checkin->kansenStatuut); $this->assertEquals(FALSE, $checkin->kansenStatuut); $this->assertEquals('Tester', $checkin->lastName); $this->assertEquals('Aalst', $checkin->location); $this->assertEquals('CC De Werf', $checkin->organiser); $this->assertInternalType('array', $checkin->organiserCardSystems); $this->assertContainsOnly('integer', $checkin->organiserCardSystems, TRUE); $this->assertCount(2, $checkin->organiserCardSystems); $this->assertEquals(array(8, 5), $checkin->organiserCardSystems); $this->assertEquals('Brussel', $checkin->userHomeCity); $this->assertEquals(50.8299126, $checkin->userHomeLocationLat); $this->assertEquals(4.3464309, $checkin->userHomeLocationLon); $this->assertEquals(10, $checkin->userPoints); $this->assertNULL($checkin->eventLocationLat); $this->assertNULL($checkin->eventLocationLon); $checkin = next($checkins->objects); $this->assertEquals(12, $checkin->type); $this->assertEquals('event', $checkin->contentType); $this->assertEquals('CC De Werf', $checkin->createdVia); $this->assertEquals(1384249920, $checkin->creationDate); $this->assertEquals('http://media.uitid.be/fis/rest/download/ce126667652776f0e9e55160f12f5478/uiv/default.png', $checkin->depiction); $this->assertEquals('7f5cf005-2a20-4d87-a55d-9bdfb2959c35', $checkin->id); $this->assertEquals('27f1e25a-1ba6-4a43-96de-0c6f99b508f3', $checkin->nodeId); $this->assertEquals('testevent uitpas betalend', $checkin->nodeTitle); $this->assertEquals(0, $checkin->points); $this->assertInternalType('boolean', $checkin->private); $this->assertEquals(FALSE, $checkin->private); $this->assertEquals('8f62d25d-4865-4e9e-955a-aedd5c748a9a', $checkin->userId); $this->assertEquals(50.939304, $checkin->eventLocationLat); $this->assertEquals(4.042009, $checkin->eventLocationLon); $this->assertEquals('Block2', $checkin->firstName); $this->assertInternalType('boolean', $checkin->kansenStatuut); $this->assertEquals(FALSE, $checkin->kansenStatuut); $this->assertEquals('Pieter', $checkin->lastName); $this->assertEquals('Aalst', $checkin->location); $this->assertEquals('CC De Werf', $checkin->organiser); $this->assertInternalType('array', $checkin->organiserCardSystems); $this->assertContainsOnly('integer', $checkin->organiserCardSystems, TRUE); $this->assertEquals(array(8, 5), $checkin->organiserCardSystems); $this->assertEquals('Aalst', $checkin->userHomeCity); $this->assertEquals(50.937793, $checkin->userHomeLocationLat); $this->assertEquals(4.0409133, $checkin->userHomeLocationLon); $this->assertEquals(10, $checkin->userPoints); $this->assertNULL($checkin->gender); // @todo Check properties of the other items as well, one by one. }
} spl_autoload_register('culturefeed_autoload'); try { $endpoint = $_SERVER['argv'][1]; //http://uitpas-acc.lodgon.com:8080/uitid/rest/ $consumer_key = $_SERVER['argv'][2]; // 62510a93c4754ed7306113e0f2391c82 $consumer_secret = $_SERVER['argv'][3]; // beea3e641e184c4a4bf3272ef4dcedf7 $searchparms = $_SERVER['argv'][4]; // "startDate=2012-09-1&endDate=2012-09-31&max=5" $path = "/uitpas/cultureevent/search"; $oc = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret); $oc->setEndpoint($endpoint); $c = new CultureFeed($oc); $query = new CultureFeed_Uitpas_Event_Query_SearchEventsOptions(); $query->readQueryString($searchparms); $data = $c->uitpas()->searchEvents($query); print_r($data); } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1); }
require_once $file; } spl_autoload_register('culturefeed_autoload'); try { $endpoint = $_SERVER['argv'][1]; $consumer_key = $_SERVER['argv'][2]; $consumer_secret = $_SERVER['argv'][3]; $promotion_id = $_SERVER['argv'][4]; if ($_SERVER['argv'][5]) { $passholder_param = new CultureFeed_Uitpas_Promotion_PassholderParameter(); $passholder_param->uitpasNumber = $_SERVER['argv'][5]; } else { $passholder_param = NULL; } $oc = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret); $oc->setEndpoint($endpoint); $c = new CultureFeed($oc); $promotion = $c->uitpas()->getPointsPromotion($promotion_id, $passholder_param); print_r($promotion); } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1); }
date_default_timezone_set('Europe/Brussels'); // require the third-party oauth library which is not properly structured to be autoloaded require_once dirname(__FILE__) . '/../../OAuth/OAuth.php'; function culturefeed_autoload($class) { $file = str_replace('_', '/', $class) . '.php'; require_once $file; } spl_autoload_register('culturefeed_autoload'); try { $endpoint = $_SERVER['argv'][1]; $consumer_key = $_SERVER['argv'][2]; $consumer_secret = $_SERVER['argv'][3]; $organizer_cdbid = $_SERVER['argv'][4]; $oc = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret); $oc->setEndpoint($endpoint); $c = new CultureFeed($oc); $data = $c->uitpas()->getDistributionKeysForOrganizer($organizer_cdbid); print_r($data); } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1); }
} spl_autoload_register('culturefeed_autoload'); try { // http://uitpas-acc.lodgon.com:8080/uitid/rest/ // 62510a93c4754ed7306113e0f2391c82 // beea3e641e184c4a4bf3272ef4dcedf7 $endpoint = $_SERVER['argv'][1]; $consumer_key = $_SERVER['argv'][2]; $consumer_secret = $_SERVER['argv'][3]; $oc = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret); $oc->setEndpoint($endpoint); $c = new CultureFeed($oc); $event_xml_str = file_get_contents(dirname(__FILE__) . "/../test/uitpas/data/events/event.xml"); $event_xml_obj = new CultureFeed_SimpleXMLElement($event_xml_str); $event = CultureFeed_Uitpas_Event_CultureEvent::createFromXML($event_xml_obj); $data = $event->toPostData(); var_dump($data); $data = $c->uitpas()->registerEvent($event); print_r($data); } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1); }
//$_SESSION['oauth_token'] = $token['oauth_token']; //$_SESSION['oauth_token_secret'] = $token['oauth_token_secret']; // Fetch the authorisation url... $auth_url = $c->getUrlAuthorize($token, $callback_url, CultureFeed::AUTHORIZE_TYPE_REGULAR); print "Now open the following URL in your browser: {$auth_url}" . PHP_EOL; print "After logging in with your UiTID you should inspect your RequestBin and find there the last request with an oauth_token and oauth_verifier." . PHP_EOL; print "Make sure the you have identified the right request, containing the oauth token: {$token['oauth_token']}" . PHP_EOL; print "Give me the oauth_verifier value now: "; $oauth_verifier = fgets(STDIN); $oauth_verifier = trim($oauth_verifier); $user_oauth_client = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret, $token['oauth_token'], $token['oauth_token_secret']); $user_oauth_client->setEndpoint($endpoint); $user_c = new CultureFeed($user_oauth_client); $new_token = $user_c->getAccessToken($oauth_verifier); $new_user_oauth_client = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret, $new_token['oauth_token'], $new_token['oauth_token_secret']); $new_user_oauth_client->setEndpoint($endpoint); $c = new CultureFeed($new_user_oauth_client); $passholder = $c->uitpas()->getPassholderByUitpasNumber($uitpas_number, $counter_consumer_key); print_r($passholder); } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1); }
print "Make sure the you have identified the right request, containing the oauth token: {$token['oauth_token']}" . PHP_EOL; print "Give me the oauth_verifier value now: "; $oauth_verifier = fgets(STDIN); $oauth_verifier = trim($oauth_verifier); $user_oauth_client = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret, $token['oauth_token'], $token['oauth_token_secret']); $user_oauth_client->setEndpoint($endpoint); $user_c = new CultureFeed($user_oauth_client); $new_token = $user_c->getAccessToken($oauth_verifier); $new_user_oauth_client = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret, $new_token['oauth_token'], $new_token['oauth_token_secret']); $new_user_oauth_client->setEndpoint($endpoint); $c = new CultureFeed($new_user_oauth_client); $query = new CultureFeed_Uitpas_Event_Query_SearchCheckinsOptions(); if ($counter_consumer_key) { $query->checkinViaBalieConsumerKey = $counter_consumer_key; } else { $query->checkinViaBalieConsumerKey = $consumer_key; } $checkins = $c->uitpas()->searchCheckins($query, $counter_consumer_key); print_r($checkins); } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1); }
// require the third-party oauth library which is not properly structured to be autoloaded require_once dirname(__FILE__) . '/../../OAuth/OAuth.php'; function culturefeed_autoload($class) { $file = str_replace('_', '/', $class) . '.php'; require_once $file; } spl_autoload_register('culturefeed_autoload'); try { $endpoint = $_SERVER['argv'][1]; $consumer_key = $_SERVER['argv'][2]; $consumer_secret = $_SERVER['argv'][3]; $oc = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret); $oc->setEndpoint($endpoint); $c = new CultureFeed($oc); $query = new CultureFeed_Uitpas_Counter_Query_SearchCounterOptions(); $query->max = 100; $counters = $c->uitpas()->searchCounters($query); print_r($counters); } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1); }
date_default_timezone_set('Europe/Brussels'); // require the third-party oauth library which is not properly structured to be autoloaded require_once dirname(__FILE__) . '/../../OAuth/OAuth.php'; function culturefeed_autoload($class) { $file = str_replace('_', '/', $class) . '.php'; require_once $file; } spl_autoload_register('culturefeed_autoload'); try { $endpoint = $_SERVER['argv'][1]; $consumer_key = $_SERVER['argv'][2]; $consumer_secret = $_SERVER['argv'][3]; $query = new CultureFeed_Uitpas_Promotion_Query_WelcomeAdvantagesOptions(); $oc = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret); $oc->setEndpoint($endpoint); $c = new CultureFeed($oc); $welcome_advantages = $c->uitpas()->searchWelcomeAdvantages($query); print_r($welcome_advantages); } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1); }
date_default_timezone_set('Europe/Brussels'); // require the third-party oauth library which is not properly structured to be autoloaded require_once dirname(__FILE__) . '/../../OAuth/OAuth.php'; function culturefeed_autoload($class) { $file = str_replace('_', '/', $class) . '.php'; require_once $file; } spl_autoload_register('culturefeed_autoload'); try { $endpoint = $_SERVER['argv'][1]; $consumer_key = $_SERVER['argv'][2]; $consumer_secret = $_SERVER['argv'][3]; $advantage_id = $_SERVER['argv'][4]; $oc = new CultureFeed_DefaultOAuthClient($consumer_key, $consumer_secret); $oc->setEndpoint($endpoint); $c = new CultureFeed($oc); $advantage = $c->uitpas()->getWelcomeAdvantage($advantage_id); print_r($advantage); } catch (Exception $e) { $eol = PHP_EOL; $type = get_class($e); print "An exception of type {$type} was thrown." . PHP_EOL; print "Code: {$e->getCode()}" . PHP_EOL; if ($e instanceof CultureFeed_Exception) { print "CultureFeed error code: {$e->error_code}" . PHP_EOL; } print "Message: {$e->getMessage()}" . PHP_EOL; print "Stack trace: {$eol}{$e->getTraceAsString()}" . PHP_EOL; exit(1); }
public function testUpdate() { $balieConsumerKey = 'b95d1bcf-533d-45ac-afcd-e015cfe86c84'; $passholder = new CultureFeed_Uitpas_Passholder(); $passholder->uitpasNumber = '1000001500601'; $passholder->name = 'Tester'; $oauth_client_stub = $this->getMock('CultureFeed_OAuthClient'); $path = 'uitpas/passholder/' . $passholder->uitpasNumber; $data = $passholder->toPostData(); $data['balieConsumerKey'] = $balieConsumerKey; $passholder_xml = file_get_contents(dirname(__FILE__) . '/data/passholder.update.succeeded.xml'); $oauth_client_stub->expects($this->any())->method('authenticatedPostAsXml')->with($path, $data)->willReturn($passholder_xml); $cf = new CultureFeed($oauth_client_stub); $cf->uitpas()->updatePassholder($passholder, $balieConsumerKey); }