/** * @param int[] $guids */ protected function preloadCurrentUserLikes(array $guids) { $owner_guid = elgg_get_logged_in_user_guid(); if (!$owner_guid) { return; } $annotation_rows = elgg_get_annotations(array('annotation_names' => 'likes', 'annotation_owner_guids' => $owner_guid, 'guids' => $guids, 'callback' => false)); foreach ($guids as $guid) { $this->data->setLikedByCurrentUser($guid, false); } foreach ($annotation_rows as $row) { $this->data->setLikedByCurrentUser($row->entity_guid, true); } }
/** * Gets the raw post if allowed * * @param int $id */ public function rawPost($id) { $item = $this->dataService->byId('MicroPost', $id); if ($item->checkPerm('Write')) { return $item; } }
public static function singleton() { if (!isset(self::$instance)) { $className = __CLASS__; self::$instance = new $className(); } return self::$instance; }
function processFeed($feed) { echo "\n<br/>Checking feed: [{$feed->FeedName}] [{$feed->FeedUrl}]"; //load the xml. $feedContents = file_get_contents($feed->FeedUrl); $feedXml = simplexml_load_string($feedContents); //check if its an RSS feed. if (!$feedXml->channel->item) { echo "Is does not appear to be RSS. Atom is not supported for the moment."; return false; } //check for new messages $newItems = array(); foreach ($feedXml->channel->item as $item) { //var_dump($item); //check if message is new $timestamp = strtotime($item->pubDate); $itemDate = date('Y-m-d H:i:s', $timestamp); //echo "<br/>itemDate: {$itemDate} ++ DateLastUpdated: {$feed->DateLastUpdated}"; if ($itemDate <= $feed->DateLastUpdated) { echo "\n<br/>Item is older, skipping. Item Date: [{$itemDate}] < Date Last Updated:[{$feed->DateLastUpdated}] [{$item->title}] "; continue; } //update the dateLastUpdated for the feed DataService::singleton()->updateFeedDateLastUpdated($feed->FeedId, $itemDate); //Add title to list $message = (string) $feed->FeedName . ": " . (string) $item->title; array_push($newItems, $message); //We can only push one item, so this will be it. break; } //update the dateLastChecked for the feed DataService::singleton()->updateFeedDateLastChecked($feed->FeedId); //if nothing found continue if (count($newItems) == 0) { return; } echo "<textarea cols=50 rows=10>"; var_dump($newItems); echo "</textarea>"; //get list of Devices associated to feed. $devices = DataService::singleton()->getFeedDevices($feed->FeedId); //var_dump($devices); //create a new message on the queue for each of them foreach ($devices as $device) { echo "in devices"; //if we are in test mode, only submit to test devices if ($_GET['onlyTestDevices'] == 1 && $device->IsTestDevice == 0) { continue; } //submit the messages to the queue foreach ($newItems as $item) { echo "\n<br/>Message submitted to queue for DeviceId: [{$device->DeviceId}] DeviceNotes: [{$device->DeviceNotes}]"; DataService::singleton()->addMessage($device->CertificateId, $device->DeviceId, $item); } } }
/** * Overridden to make sure the dashboard page is attached to the correct controller * @return type */ protected function getRecord() { $id = (int) $this->request->param('ID'); if (!$id) { $id = (int) $this->request->requestVar('ID'); } if ($id) { $type = $this->stat('model_class'); $action = $this->request->param('Action'); if ($action == 'dashlet' || $action == 'widget') { $type = 'Dashlet'; } $item = $this->dataService->byId($type, $id); if ($item instanceof DashboardPage) { $item->setController($this); } return $item; } }
// ============= Then get students by name operation ======================== // ------------ Here we first prepare the inner query ------------- $inner_query_input_format = array("studentID" => "STRING"); $inner_query_output_format = array("resultElement" => "subjects", "rowElement" => "subject", "elements" => array("name" => "subjectName", "marks" => "marks")); $inner_query_sql = "SELECT subjectName, marks FROM Marks m, Subjects s where m.studentId = ? and m.subjectID = s.subjectId"; $inner_query = array("inputFormat" => $inner_query_input_format, "outputFormat" => $inner_query_output_format, "sql" => $inner_query_sql); // ------------- Secondly we prepare the outer query and set the inner query in output format ----- $out_query_input_format = array("name" => "STRING"); $output_format = array("resultElement" => "students", "rowElement" => "student", "elements" => array("name" => "studentName", "age" => "studentAge", "address" => "studentAddress"), "queries" => array($inner_query)); $sql = "SELECT * FROM Students where StudentName = ?"; $get_students_with_name_op = array("inputFormat" => $input_format, "outputFormat" => $output_format, "sql" => $sql); $get_students_with_name_url = array("HTTPMethod" => "GET", "RESTLocation" => "students/{name}"); // ================================================================== // ============= Then get marks per student, per subject operation ======================== $input_format = array("student" => "STRING", "subject" => "STRING"); $output_format = array("resultElement" => "Marks", "rowElement" => "mark", "texts" => array("marks")); $sql = "SELECT marks FROM Marks, Subjects, Students where StudentName = ? and SubjectName = ? " . "and Marks.subjectId = Subjects.subjectId and Marks.studentID = Students.StudentId;"; $marks_per_student_per_subject_op = array("inputFormat" => $input_format, "outputFormat" => $output_format, "sql" => $sql); //$marks_per_student_per_subject_url = array("HTTPMethod" => "GET", "RESTLocation" => "marks/{student}/{subject}"); $marks_per_student_per_subject_url = array("HTTPMethod" => "GET", "RESTLocation" => "students/{student}/marks/{subject}"); // ================================================================== // list of operations $operations = array("getSubjects" => $get_subjects_op, "getSubjectsWithName" => $get_subjects_with_name_op, "marksPerStudentPerSubject" => $marks_per_student_per_subject_op, "getStudentsWithName" => $get_students_with_name_op, "getStudents" => $get_students_op); // list of rest url mappping (operation => url) $restmap = array("getSubjects" => $get_subjects_url, "getSubjectsWithName" => $get_subjects_with_name_url, "getStudents" => $get_students_url, "marksPerStudentPerSubject" => $marks_per_student_per_subject_url, "getStudentsWithName" => $get_students_with_name_url); // creating DSService and reply $service = new DataService(array("config" => $config, "operations" => $operations, "RESTMapping" => $restmap)); $service->reply(); ?>
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Iterate through all Customers, even if it takes multiple pages $i = 0; while (1) { $allCustomers = $dataService->FindAll('Customer', $i, 500); if (!$allCustomers || 0 == count($allCustomers)) { break; } foreach ($allCustomers as $oneCustomer) { echo "Customer[" . $i++ . "]: {$oneCustomer->CompanyName}\n"; echo "\t * Id: [{$oneCustomer->Id}]\n"; echo "\t * Active: [{$oneCustomer->Active}]\n"; echo "\n";
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php'; require_once PATH_SDK_ROOT . 'QueryFilter/QueryMessage.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } $allCompanies = $dataService->FindAll('CompanyInfo'); foreach ($allCompanies as $oneCompany) { $oneCompanyReLookedUp = $dataService->FindById($oneCompany); echo "Company Name: {$oneCompanyReLookedUp->CompanyName}\n"; } /* Example output: Company Name: MyCo Production LLC Company Name: ACME Inc. Company Name: Jones Corp */
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Add an account set up as an Accounts Receivable account $accountObj = new IPPAccount(); $accountObj->Name = "Accounts Recv (" . rand() . ")"; if (IntuitServicesType::QBO == $serviceType) { $accountObj->AccountSubType = 'AccountsReceivable'; } else { $accountObj->AccountType = 'Accounts Receivable'; } $resultingObj = $dataService->Add($accountObj); echo "New A/R Account Id: {$resultingObj->Id}\n"; /* Example output:
$customerOrdersSQL_queries = array("query1" => $customerNameSQL_1_1_query); // building the output elements order for the customerOrdersSQL $customerOrdersSQL_elements_order = array("Order_number", "Order_date", "Status", "OrderId", "query1"); // building the output format for the customerOrdersSQL $customerOrdersSQL_output_format = array("resultElement" => "Orders", "rowElement" => "Order", "elements" => $customerOrdersSQL_elements, "attributes" => array("OrderId" => "ORDERNUMBER"), "queries" => $customerOrdersSQL_queries, "elementsOrder" => $customerOrdersSQL_elements_order); // building the sql for the customerOrdersSQL $customerOrdersSQL_sql = "select o.ORDERNUMBER,o.ORDERDATE, o.STATUS,o.CUSTOMERNUMBER from ds.Orders o"; // building the input mapping for the customerOrdersSQL $customerOrdersSQL_input_mapping = NULL; $customerOrders = array("inputFormat" => $customerOrdersSQL_input_format, "outputFormat" => $customerOrdersSQL_output_format, "sql" => $customerOrdersSQL_sql, "inputMapping" => $customerOrdersSQL_input_mapping); // ------------finished queries for customerOrders-------------- // ----------building the queries for customerName ------------ // building the input format for the customerNameSQL $customerNameSQL_input_format = array("customerNumber" => "INTEGER"); // building the output elements for the customerNameSQL $customerNameSQL_elements = array("Name" => "CUSTOMERNAME"); // building the output elements order for the customerNameSQL $customerNameSQL_elements_order = array("Name"); // building the output format for the customerNameSQL $customerNameSQL_output_format = array("resultElement" => "Customers", "rowElement" => "Customer", "elements" => $customerNameSQL_elements, "elementsOrder" => $customerNameSQL_elements_order); // building the sql for the customerNameSQL $customerNameSQL_sql = "select c.CUSTOMERNAME from ds.Customers c where c.CUSTOMERNUMBER = ?"; // building the input mapping for the customerNameSQL $customerNameSQL_input_mapping = array("customerNumber" => "CUSTOMERNUMBER"); $customerName = array("inputFormat" => $customerNameSQL_input_format, "outputFormat" => $customerNameSQL_output_format, "sql" => $customerNameSQL_sql, "inputMapping" => $customerNameSQL_input_mapping); // ------------finished queries for customerName-------------- // building the operations array $operations = array("customerOrders" => $customerOrders, "customerName" => $customerName); // create the DataService object and reply $ds = new DataService(array("operations" => $operations, "config" => $config, "serviceName" => "NextedQuerySample")); $ds->reply();
## ## This file is part of APNS. ## ## APNS is free software: you can redistribute it and/or modify ## it under the terms of the GNU Lesser General Public License as ## published by the Free Software Foundation, either version 3 of ## the License, or (at your option) any later version. ## ## APNS is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with APNS. If not, see <http://www.gnu.org/licenses/>. ## ## ## $Id: getSubscriptions.php 168 2010-08-28 01:24:04Z Benjamin Ortuzar Seconde $ ## require_once "../config.php"; require_once "../classes/DataService.php"; if (!isset($_REQUEST['certificateId']) || $_REQUEST['certificateId'] == '') { exit("\nParameter not set"); } //Get the certificate object $certificate = DataService::singleton()->GetCertificate($_REQUEST['certificateId']); //var_dump($certificate); //get the subscriptions $subscriptionsArray = DataService::singleton()->getAppSubscriptions($certificate->AppId); //var_dump($subscriptionsArray); echo json_encode($subscriptionsArray);
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Add a customer $customerObj = new IPPCustomer(); $customerObj->Name = "Name" . rand(); $customerObj->CompanyName = "CompanyName" . rand(); $customerObj->GivenName = "GivenName" . rand(); $customerObj->DisplayName = "DisplayName" . rand(); $resultingCustomerObj = $dataService->Add($customerObj); echo "Created Customer Id={$resultingCustomerObj->Id}. Reconstructed response body:\n\n"; $xmlBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($resultingCustomerObj, $urlResource); echo $xmlBody . "\n"; // Update Customer Obj $resultingCustomerObj->GivenName = "New Name " . rand();
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } $rnd = rand(); $taxRateDetails = new IPPTaxRateDetails(); $taxRateDetails->TaxRateName = "myNewTaxRateName_{$rnd}"; $taxRateDetails->RateValue = "7"; $taxRateDetails->TaxAgencyId = "1"; $taxRateDetails->TaxApplicableOn = "Sales"; $taxService = new IPPTaxService(); $taxService->TaxCode = 'MyTaxCodeName_' . $rnd; $taxService->TaxRateDetails = array($taxRateDetails); $result = $dataService->Add($taxService); if (empty($result)) { echo "\n Something was wrong. Please check logs";
$realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); $serviceContext->IppConfiguration->Message->Response->SerializationFormat = SerializationFormat::Json; $serviceContext->IppConfiguration->Message->Request->SerializationFormat = SerializationFormat::Json; $serviceContext->IppConfiguration->BaseUrl->Qbo = ConfigurationManager::BaseURLSettings(strtolower(IntuitServicesType::QBO)); $serviceContext->baseserviceURL = $serviceContext->GetBaseURL(); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } $result = $dataService->Add(createTransfer()); echo showMe($result); print_r($result); ################################################################################ # Domain Objects example # ################################################################################ function createTransfer() { $from = new IPPReferenceType(); $from->name = "Checking"; $from->value = 35; $to = new IPPReferenceType();
<?php require_once 'config.php'; require_once 'classes/DataService.php'; if (!isset($_REQUEST['deviceToken']) || $_REQUEST['deviceToken'] == '') { echo $_REQUEST['deviceToken']; exit("No deviceToken set"); } if (!isset($_REQUEST['appId']) || $_REQUEST['appId'] == '') { echo $_REQUEST['appId']; exit('Not appId set'); } echo "<br/>Registering Device (if it does not exist already)"; DataService::singleton()->RegisterDevice($_REQUEST['deviceToken']); echo "<br/>Enabling Device for App: [{$_REQUEST['appId']}] (if not enabled already)"; DataService::singleton()->setDeviceActive($_REQUEST['deviceToken'], $_REQUEST['appId'], 1); //optional if (isset($_REQUEST['appSubscriptionId'])) { echo "<br/>Registering for Subscription" . $_REQUEST['appSubscriptionId']; DataService::singleton()->updateAppSubscription($_REQUEST['deviceToken'], $_REQUEST['appSubscriptionId'], 1); } if (isset($_REQUEST['feedUrl'])) { echo "\n<br/>Register Feed: {$_REQUEST['feedUrl']} "; $feedId = DataService::singleton()->registerFeed($_REQUEST['feedUrl']); echo "\n<br/>FeedId: {$feedId}"; DataService::singleton()->subscribeDeviceToFeed($_REQUEST['deviceToken'], $_REQUEST['appId'], $feedId, $_REQUEST['feedEnable']); }
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Run a query $entities = $dataService->Query("SELECT * FROM Customer"); // Echo some formatted output $i = 0; foreach ($entities as $oneCustomer) { echo "Customer[{$i}] DisplayName: {$oneCustomer->DisplayName}\t(Created at {$oneCustomer->MetaData->CreateTime})\n"; $i++; } /* Example output: Customer[0] GivenName: Jimco LLC (Created at 2013-06-29T22:06:45-07:00)
require_once PATH_SDK_ROOT . 'Core/OperationControlList.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Add an employee $employeeObj = new IPPEmployee(); $employeeObj->Name = "Employee"; $employeeObj->FamilyName = "Intuit"; $employeeObj->GivenName = "Employee"; $employeeObj->DisplayName = "Emp" . rand(); $resultingEmployeeObjObj = $dataService->Add($employeeObj); // Echo some formatted output echo '<a href="javascript:void(0)" onclick="goHome()">Home</a>'; echo ' '; echo '<a href="javascript:void(0)" onclick="return intuit.ipp.anywhere.logout(function () { window.location.href = \'http://localhost/PHPSample/index.php\'; });">Sign Out</a> '; echo ' ';
<div id="main"> <form method="POST" action="" onsubmit="javascript:return confirmSubmit()"> <fieldset> <legend>Push Notifications</legend> <label for="message">Message:</label><br/> <textarea cols="20" rows="4" name="message" id="message"></textarea> <br/> <label for="certificateId">Certificate:</label><br/> <select name="certificateId" id="certificateId"> <?php //get all apps $certificatesArray = DataService::singleton()->getCertificates(); foreach ($certificatesArray as $certificate) { echo "<option value='{$certificate->CertificateId}'>{$certificate->CertificateName}</option>"; } ?> </select> <br/> <!--! subscriptions container--> <div id="subscriptions"> <label for="subscriptionId">Subscription:</label><br/> <select name="subscriptionId" id="subscriptionId"> </select> </div>
<?php /* * Copyright 2005,2006 WSO2, Inc. http://wso2.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ require_once "wso2/DataServices/DataService.php"; require_once "constants.php"; // database configuration $config = array("db" => "mysql", "username" => DB_USERNAME, "password" => DB_PASSWORD, "dbname" => "ds", "dbhost" => "localhost"); // the input format array(param_name => SQL_type) $inputFormat = array("lastName" => "STRING", "firstName" => "STRING"); // the output format (visit the API from http://wso2.org/wiki/display/wsfphp/API+for+Data+Services+Revised) $outputFormat = array("resultElement" => "customer-addresse", "rowElement" => "customer-address", "elements" => array("contactlastname" => "CONTACTLASTNAME", "contactfirstname" => "CONTACTFIRSTNAME", "addressline1" => "ADDRESSLINE1", "addressline2" => "ADDRESSLINE2", "city" => "CITY", "state" => "STATE", "postalcode" => "POSTALCODE", "country" => "COUNTRY"), "attributes" => array("customernumber" => "CUSTOMERNUMBER"), "elementsOrder" => array("customernumber", "contactfirstname", "contactlastname", "addressline1", "addressline2", "city", "state", "postalcode", "country")); // the sql to execute $sql = "select CUSTOMERNUMBER, CONTACTLASTNAME, CONTACTFIRSTNAME, ADDRESSLINE1, ADDRESSLINE2, CITY, STATE, POSTALCODE, COUNTRY from Customers where CONTACTLASTNAME = ? and CONTACTFIRSTNAME = ?"; // operations are consists of inputFormat (optional), outputFormat(required), sql(sql), input_mapping(optional) $operations = array("customerAddress" => array("inputFormat" => $inputFormat, "outputFormat" => $outputFormat, "sql" => $sql)); $my_data_service = new DataService(array("config" => $config, "operations" => $operations, "serviceName" => "CustomerAddress")); $my_data_service->reply();
require_once 'config.php'; require_once 'classes/DataService.php'; require_once 'classes/Apns.php'; echo "<br/>Started processing Feedback"; //get the certificates $certificates = DataService::singleton()->getCertificates(); foreach ($certificates as $certificate) { //only process apps that have a certificate associated to it. if ($certificate->KeyCertFile == '') { echo "<br/>Certfile not set for App: [{$certificate->CertificateName}]"; continue; } //var_dump($certificate); //connect to feedback server $certificatePath = $certificateFolder . '/' . $certificate->KeyCertFile; $server = DataService::singleton()->getCertificateServer($certificate->CertificateId, 2); $apns = new apns($server->ServerUrl, $certificatePath, $certificate->Passphrase); //get tokens $feedbackTokens = $apns->getFeedbackTokens(); //close connection unset($apns); //print the number of tokens to check for $countTotal = count($feedbackTokens); echo "<br/>There are [{$countTotal}] tokens notified by feedback"; //loop trough the tokens foreach ($feedbackTokens as $feedbackToken) { //only DeActivate devices that where updated before they where removed. Otherwise the user could of installed the app again. DataService::singleton()->setDeviceInactive($feedbackToken['devtoken'], $app->AppId, $feedbackToken['timestamp']); } } echo "<br/>Completed processing Feedback";
/** * @param kResource $resource * @param entry $dbEntry * @param asset $asset */ protected function attachResource(kResource $resource, entry $dbEntry, asset $asset = null) { $service = null; switch ($dbEntry->getType()) { case entryType::MEDIA_CLIP: $service = new MediaService(); $service->initService('media', 'media', $this->actionName); break; case entryType::MIX: $service = new MixingService(); $service->initService('mixing', 'mixing', $this->actionName); break; case entryType::PLAYLIST: $service = new PlaylistService(); $service->initService('playlist', 'playlist', $this->actionName); break; case entryType::DATA: $service = new DataService(); $service->initService('data', 'data', $this->actionName); break; case entryType::LIVE_STREAM: $service = new LiveStreamService(); $service->initService('liveStream', 'liveStream', $this->actionName); break; default: throw new KalturaAPIException(KalturaErrors::ENTRY_TYPE_NOT_SUPPORTED, $dbEntry->getType()); } $service->attachResource($resource, $dbEntry, $asset); }
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } echo '<table width="500" cellspacing="5" cellpadding="5" border="1">'; echo '<tr> <th>Name</th> <th> Number </th> <th>Type</th> <th> Subtype </th> </tr>'; // Iterate through all Accounts, even if it takes multiple pages $startPosition = 1; $maxResult = 1000; $count = 0; while (1) { $allAccounts = $dataService->FindAll('Account', $startPosition, $maxResult); if (!$allAccounts || 0 == count($allAccounts)) { break; } foreach ($allAccounts as $oneAccount) {
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Run a query $entities = $dataService->Query("SELECT * FROM TaxRate"); // Echo some formatted output if (count($entities) > 0) { $i = 0; foreach ($entities as $oneTaxRate) { echo "TaxRate[{$i}] Name: {$oneTaxRate->Name}\tRate {$oneTaxRate->RateValue} AgencyRef {$oneTaxRate->AgencyRef} (SpecialTaxType {$oneTaxRate->SpecialTaxType})\n"; $i++; } } /* Example output:
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } $linedet = new IPPJournalEntryLineDetail(); $linedet->PostingType = 'Debit'; $linedet->AccountRef = 9; $line = new IPPLine(); $line->Id = 0; $line->Description = 'test journal'; $line->Amount = 2.0; $line->DetailType = 'JournalEntryLineDetail '; $line->JournalEntryLineDetail = $linedet; $linedet2 = new IPPJournalEntryLineDetail(); $linedet2->PostingType = 'Credit'; $linedet2->AccountRef = 8;
require_once 'classes/DataService.php'; require_once 'classes/Apns.php'; echo "<br/>Started processing message queue"; //get the certificates $certificates = DataService::singleton()->getCertificates(); foreach ($certificates as $certificate) { //get N new messages from queue. We can get more messages on the next schedule echo "<br/>Getting messages for: [{$certificate->CertificateName}]"; //var_dump($certificate); $messagesArray = DataService::singleton()->getMessages($certificate->CertificateId, MessageStatus::UNPROCESSED, 1000); //if no messages for app continue with next if (count($messagesArray) == 0) { continue; } //connect to apple push notification server with the app credentials $certificatePath = $certificateFolder . '/' . $certificate->KeyCertFile; echo $certificatePath; $server = DataService::singleton()->getCertificateServer($certificate->CertificateId, 1); //var_dump($server); $apns = new apns($server->ServerUrl, $certificatePath, $certificate->Passphrase); //send each message foreach ($messagesArray as $message) { //send payload to device $apns->sendMessage($message->DeviceToken, $message->Message, $message->Badge, $message->Sound); //mark as sent DataService::singleton()->setMessageStatus($message->MessageId, 2); } //execute the APNS desctructor so the connection is closed. unset($apns); } echo "<br/>Completed processing messages queue";
require_once PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Iterate through all Accounts, even if it takes multiple pages $i = 1; while (1) { $allAccounts = $dataService->FindAll('Account', $i, 500); if (!$allAccounts || 0 == count($allAccounts)) { break; } foreach ($allAccounts as $oneAccount) { echo "Account[" . $i++ . "]: {$oneAccount->Name}\n"; echo "\t * Id: [{$oneAccount->Id}]\n"; echo "\t * AccountType: [{$oneAccount->AccountType}]\n"; echo "\t * AccountSubType: [{$oneAccount->AccountSubType}]\n";
/** * Retrieves specified entity based passed page number and page size * * @param string $urlResource Entity type to Find * @return array Returns an array of entities of specified type. */ public function FindAll($entityName, $pageNumber = 0, $pageSize = 500) { $this->serviceContext->IppConfiguration->Logger->RequestLog->Log(TraceLevel::Info, "Called Method FindAll."); $phpClassName = DataService::decorateIntuitEntityToPhpClassName($entityName); // Handle some special cases if (strtolower('company') == strtolower($entityName)) { $entityName = 'CompanyInfo'; } if ('QBO' == $this->serviceContext->serviceType) { $httpsContentType = CoreConstants::CONTENTTYPE_APPLICATIONTEXT; } else { $httpsContentType = CoreConstants::CONTENTTYPE_TEXTPLAIN; } $httpsUri = implode(CoreConstants::SLASH_CHAR, array('company', $this->serviceContext->realmId, 'query')); $httpsPostBody = "select * from {$entityName} startPosition {$pageNumber} maxResults {$pageSize}"; $requestParameters = $this->getPostRequestParameters($httpsUri, $httpsContentType); $restRequestHandler = new SyncRestHandler($this->serviceContext); list($responseCode, $responseBody) = $restRequestHandler->GetResponse($requestParameters, $httpsPostBody, NULL); $parsedResponseBody = NULL; try { $responseXmlObj = simplexml_load_string($responseBody); if ($responseXmlObj && $responseXmlObj->QueryResponse) { $parsedResponseBody = $this->responseSerializer->Deserialize($responseXmlObj->QueryResponse->asXML(), FALSE); } } catch (Exception $e) { IdsExceptionManager::HandleException($e); } return $parsedResponseBody; }
include_once "application.php"; include_once "apps/data_service.php"; include_once "apps/routecoorddistances.php"; $stop = $_GET["stop"]; $route = $_GET["route"]; //$favs = $_COOKIE["favs"]; //$favArray = explode(";",$favs); //foreach ($favArray as $favStopRoutePair) //{ // $separated = explode($favStopRoutePair); // $favStop = $separated[0]; // $favStop = $separated[0]; // //} ?> <div data-role="page" id="eta"> <div data-role="header" class="ui-bar" data-inline="true"> <h1>RPI Shuttle Tracking</h1> <a href="#" data-icon="plus" class="ui-btn-right" data-theme="c">Fav</a> </div> <div data-role="content"> <?php DataService::drawExtraETA($route, $stop); ?> </div> <?php //include("footer.php"); ?> </div>
require_once PATH_SDK_ROOT . 'QueryFilter/QueryMessage.php'; //Specify QBO or QBD $serviceType = IntuitServicesType::QBO; // Get App Config $realmId = ConfigurationManager::AppSettings('RealmID'); if (!$realmId) { exit("Please add realm to App.Config before running this sample.\n"); } // Prep Service Context $requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret')); $serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator); if (!$serviceContext) { exit("Problem while initializing ServiceContext.\n"); } // Prep Data Services $dataService = new DataService($serviceContext); if (!$dataService) { exit("Problem while initializing DataService.\n"); } // Build a query $oneQuery = new QueryMessage(); $oneQuery->sql = "SELECT"; $oneQuery->entity = "Customer"; $oneQuery->orderByClause = "FamilyName"; $oneQuery->startposition = "1"; $oneQuery->maxresults = "4"; // Run a query $queryString = $oneQuery->getString(); $entities = $dataService->Query($queryString); // Echo some formatted output $i = 0;
rt - route ID st - stop ID output: JSON formatted tracking information sh and st are optional and give you specific eta about that shuttle or stop action - get_next_eta || get_all_eta sh - shuttle ID rt - route ID st - stop ID examples: abstractedsheep.com/~ashulgach/dataservice.php?action=get_next_eta # gets the next eta for all stops abstractedsheep.com/~ashulgach/dataservice.php?action=get_next_eta&rt=1 # gets the next eta for West Route abstractedsheep.com/~ashulgach/dataservice.php?action=get_all_eta # gets all the etas for all shuttles and stops */ include "application.php"; include "apps/data_service.php"; $data_service = new DataService(); $action = $_REQUEST['action']; $shuttle_id = $_REQUEST['sh']; $route_id = $_REQUEST['rt']; $stop_id = $_REQUEST['st']; switch ($action) { case 'get_next_eta': echo $data_service->getNextEta($route_id, $stop_id); DataServiceData::recordStats("Get Next ETA"); exit; case 'get_all_eta': echo $data_service->getAllEta($route_id, $shuttle_id, $stop_id); DataServiceData::recordStats("Get All ETA"); exit; case 'get_all_extra_eta': echo $data_service->getAllExtraEta($route_id, $shuttle_id, $stop_id);