Skip to content

Commit d273ad6

Browse files
committedDec 23, 2010
first import
0 parents  commit d273ad6

20 files changed

+1285
-0
lines changed
 

‎Readme.pdf

145 KB
Binary file not shown.

‎config/config.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* @copyright Copyright 2010 metaio GmbH. All rights reserved.
4+
* @link http://www.metaio.com
5+
* @author Bernhard Heindl
6+
**/
7+
8+
//General channel stuff
9+
define('JUNAIO_API_HOST', 'http://api.junaio.com'); // URL to the junaio API
10+
define('AUTH_DATE_TOLERANCE', 15 * 60 * 1000); // Set time period for valid requests: 15 minutes
11+
define('JUNAIO_KEY', '77207d292b46f3023684608b36ae4d7b'); // Junaio developer key

‎example/example.php

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* @copyright Copyright 2010 metaio GmbH. All rights reserved.
4+
* @link http://www.metaio.com
5+
* @author Frank Angermann
6+
*
7+
* DESCRIPTION: This example shows how to send requests to the API instead of receiving them via the callback URL.
8+
* Sending requests are necessary for creating channel notifications or encrypting models.
9+
*
10+
* Please see http://www.junaio.com -> developer -> api for further information or contact us at developer@junaio.com
11+
**/
12+
require_once realpath(dirname(dirname(__FILE__))) . '/library/client.php';
13+
14+
$oJunaioClient = new JunaioApiClient();
15+
16+
try {
17+
18+
$oResponse = $oJunaioClient->request(
19+
'/channels/notifications/create/[YOUR_CHANNEL_ID]/',
20+
'POST',
21+
array(
22+
'text' => 'Your message to subscribers of your channel'
23+
),
24+
array(
25+
'username' => 'password'
26+
)
27+
);
28+
29+
// Zend response
30+
var_dump($oResponse);
31+
32+
} catch (Exception $e) {
33+
echo $e->getMessage();
34+
}

‎favicon.gif

Loading

‎favicon.ico

Whitespace-only changes.

‎html/.htaccess

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
RewriteEngine On
2+
3+
RewriteCond %{REQUEST_FILENAME} !-f
4+
RewriteCond %{REQUEST_FILENAME} !-d
5+
RewriteCond %{REQUEST_FILENAME} !-l
6+
7+
RewriteRule .* index.php [L]
8+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
9+

‎html/_.htaccess

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
RewriteEngine On
2+
3+
RewriteCond %{REQUEST_FILENAME} !-f
4+
RewriteCond %{REQUEST_FILENAME} !-d
5+
RewriteCond %{REQUEST_FILENAME} !-l
6+
7+
RewriteRule .* index.php [L]
8+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

‎html/favicon.gif

Loading

‎html/favicon.ico

Whitespace-only changes.

‎html/index.php

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* @copyright Copyright 2009 metaio GmbH. All rights reserved.
4+
* @link http://www.metaio.com
5+
* @author Bernhard Heindl
6+
**/
7+
8+
require_once '../config/config.php';
9+
require_once '../library/junaio.class.php';
10+
11+
// Check junaio authentication header
12+
// Settings for the authentication can be found in config.php
13+
if (!Junaio::checkAuthentication()) {
14+
header('HTTP/1.0 401 Unauthorized');
15+
exit;
16+
}
17+
18+
//if issues occur with htaccess, also the path variable can be used
19+
//
20+
//htaccess rewrite enabled:
21+
//Callback URL: http://www.callbackURL.com
22+
//
23+
//htacces diabled:
24+
//Callback URL: http://www.callbackURL.com/?path=
25+
26+
if(isset($_GET['path']))
27+
$path = $_GET['path'];
28+
else
29+
$path = $_SERVER['REQUEST_URI'];
30+
31+
$aUrl = explode('/', $path);
32+
33+
// Include xml generation file, depending on the request
34+
// pois/search -> search.php
35+
// pois/event -> event.php
36+
// channels/subscribe -> subscribe.php
37+
38+
if(in_array('pois', $aUrl))
39+
{
40+
if(in_array_substr('event', $aUrl))
41+
{
42+
include '../src/event.php';
43+
exit;
44+
}
45+
else if(in_array_substr('search', $aUrl))
46+
{
47+
include '../src/search.php';
48+
exit;
49+
}
50+
}
51+
else if(in_array('channels', $aUrl))
52+
{
53+
if(in_array_substr('subscribe', $aUrl))
54+
{
55+
include '../src/subscribe.php';
56+
exit;
57+
}
58+
}
59+
60+
// Wrong url
61+
header('HTTP/1.0 404 Not found');
62+
63+
function in_array_substr($needle, $haystack)
64+
{
65+
foreach($haystack as $value)
66+
{
67+
if(strpos($value, $needle) !== false)
68+
return true;
69+
}
70+
71+
return false;
72+
}

‎html/resources/pois_event.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?><results>
2+
<poi id="poi3" interactionfeedback="click">
3+
<name><![CDATA[Ein Ballon]]></name>
4+
<author>metaio GmbH</author>
5+
<l>48.161036,11.55107,0</l>
6+
<o>0,0,0</o>
7+
<mime-type>model/md2</mime-type>
8+
<mainresource>http://www.junaio.com/publisherDownload/tutorial/balloon.md2_enc</mainresource>
9+
<route>false</route>
10+
<s>30</s>
11+
<force3d>true</force3d>
12+
<resources>
13+
<resource>http://www.junaio.com/publisherDownload/tutorial/balloon.png</resource>
14+
</resources>
15+
<behaviours>
16+
<behaviour type="idle">
17+
<length>0</length>
18+
<node_id>action</node_id>
19+
</behaviour>
20+
</behaviours>
21+
</poi>
22+
</results>

‎html/resources/pois_search.xml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?><results>
2+
<poi id="poi3" interactionfeedback="click">
3+
<name><![CDATA[Ein UFO]]></name>
4+
<author>metaio GmbH</author>
5+
<date/>
6+
<l>48.161036,11.55107,0</l>
7+
<o>0,0,0</o>
8+
<mime-type>model/md2</mime-type>
9+
<mainresource>http://www.junaio.com/publisherDownload/tutorial/ufo3.md2_enc</mainresource>
10+
<route>false</route>
11+
<s>8</s>
12+
<force3d>true</force3d>
13+
<resources>
14+
<resource>http://www.junaio.com/publisherDownload/tutorial/texture_ufo.png</resource>
15+
</resources>
16+
<behaviours>
17+
<behaviour type="idle">
18+
<length>0</length>
19+
<node_id>idle</node_id>
20+
</behaviour>
21+
<behaviour type="click">
22+
<length>0</length>
23+
<node_id>explosion</node_id>
24+
</behaviour>
25+
</behaviours>
26+
</poi>
27+
</results>

‎junaio_library_beta.zip

137 KB
Binary file not shown.

‎library/client.php

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
/**
3+
* @copyright Copyright 2009 metaio GmbH. All rights reserved.
4+
* @link http://www.metaio.com
5+
* @author Bernhard Heindl
6+
**/
7+
8+
// Set Zend Framework include path
9+
set_include_path(
10+
implode(
11+
PATH_SEPARATOR,
12+
array(
13+
get_include_path(),
14+
)
15+
)
16+
);
17+
18+
require_once '../config/config.php';
19+
require_once 'Zend/Http/Client.php';
20+
21+
setlocale(LC_TIME, array('en_US.UTF-8', 'en_US.UTF8','en.UTF8','en.UTF-8', "En-Us"));
22+
23+
class JunaioApiClient {
24+
25+
/**
26+
* Execute request
27+
*
28+
* @param $sUrl
29+
* @param $sMethod
30+
* @param $aParams
31+
* @param $aAuth
32+
* @param $aFiles
33+
* @return Zend_Http_Response
34+
*/
35+
public function request($sUrl, $sMethod = 'GET', $aParams = array(), $aAuth = array(), $aFiles = array()) {
36+
37+
// Instantiate http client
38+
$oClient = new Zend_Http_Client();
39+
40+
// Determine request method
41+
switch ($sMethod) {
42+
case 'DELETE':
43+
$iMethod = Zend_Http_Client::DELETE;
44+
break;
45+
case 'POST':
46+
$iMethod = Zend_Http_Client::POST;
47+
break;
48+
case 'GET':
49+
default:
50+
$iMethod = Zend_Http_Client::GET;
51+
break;
52+
}
53+
54+
// Set GET-Parameter
55+
if (!empty($aParams) && $iMethod === Zend_Http_Client::GET) {
56+
$aTokens = array();
57+
foreach ($aParams as $sKey => $mValue) {
58+
$aTokens[] = $sKey . '=' . $mValue;
59+
}
60+
$sUrl .= '?' . implode('&', $aTokens);
61+
}
62+
63+
// Set POST-Parameter
64+
if (!empty($aParams) && $iMethod === Zend_Http_Client::POST) {
65+
foreach ($aParams as $sKey => $mParam) {
66+
$oClient->setParameterPost($sKey, $mParam);
67+
}
68+
}
69+
70+
// Set files
71+
if (!empty($aFiles) && $iMethod === Zend_Http_Client::POST) {
72+
foreach ($aFiles as $sKey => $sFile) {
73+
$oClient->setFileUpload($sFile, $sKey);
74+
}
75+
}
76+
77+
// Set authentication header
78+
if (!empty($aAuth)) {
79+
foreach ($aAuth as $sUser => $sPassword) {
80+
81+
$sDate = strftime('%a, %d %b %Y %H:%M:%S GMT');
82+
$oClient->setHeaders('Date', $sDate);
83+
84+
$sAccessKey = base64_encode(md5($sUser));
85+
$sSignatureString = base64_encode(md5(
86+
mb_convert_case(md5($sPassword), MB_CASE_LOWER) . "\n" .
87+
$iMethod . "\n" .
88+
$sUrl . "\n" .
89+
'Date: ' . $sDate . "\n"
90+
));
91+
92+
$oClient->setHeaders('Authorization', 'metaioWorld ' . $sAccessKey . ':' . $sSignatureString);
93+
94+
}
95+
}
96+
97+
$oClient->setUri(JUNAIO_API_HOST . $sUrl);
98+
99+
return $oClient->request($iMethod);
100+
101+
}
102+
103+
}

0 commit comments

Comments
 (0)
Please sign in to comment.