The Twitter fail whale error message.
Image via Wikipedia

@bracitat now have 309 real followers after 4459 tweets.

As before (see previous blog) we block spam followers and then follow all persons who are from our target region (Sweden/Norway). As of today we follow 211 people. This means we are up from around 10% to 14,4% in relation to number of tweets and followers. But what is interesting is that the number of people we follow, or what we call valid followers, is now 4,7%.

It also seems that we are getting a larger amount of RT’s.

Our bot test will continue.

Reblog this post [with Zemanta]
File Transfer Graffiti
Image by Micah68 via Flickr

We needed to build a socket FTP client in FLEX. When done we ran into the problem on how to setup a cross-domain policy file which we never tried before. This post is based on Flash Player version 10 and above. Older versions work in other ways so please compile for ver. 10.

I will not go through all the things we did wrong and all the steps needed to set this up. But I will underline the things that set us on the right track, things that are of major importance to get this working.

HTTP based policy file out of the question
You might be tempted to use HTTP-based policy-file retrieval which will work for any port above 1024! So for FTP this is out of the question!

Socket based policy file retrieval
Setting up a socket server just to serve the policy XML file seems strange but is needed. You can setup the socket server in PHP, Python, Java or any other language that supports sockets.

Port
You need to open up a port on which the socket server can monitor the requests. Adobe recommends port 843. It is important that the socket server port is set below 1024. FTP usually resides at port 21 and if the policy socket is above 1024 it cant give you access to ports below 1024. So stay below 1024!

Read this
To get a working socket server read the following post at adobe.com.

Hope that this few steps will help you get this working faster then we did.

Reblog this post [with Zemanta]

Want to create a Layar layer with a PHP backend?

So you have seen the cool augmented reality applications for iPhone and Andriod! Now you want to make use of this technology in your project. With the Layar application you are not far from that goal.
The Layar API is pretty straight forward but this post might get you up to speed even faster.
The backend we are going to build is based on MySQL and on PHP ver. 5.2. If you don’t have 5.2 you can build the JSON manually.

Layar API

I’ll assume that you have read the instructions at http://dev.layar.com/publishing/ and received your developer account.
At the developer site login and add a new layer. The “POI URL” should point to the PHP file below in this post. Fill in as much information you can and save the layer.
Example: http://your_site.net/my_layer.php

The database

You could store your locations in a XML file or in whatever you like. But the good thing about SQL is that you can query for a radius. This means that you let the query do the actual calculation on which position to send back to the Layar API. So this is where the backend magic actually happens.

1. Create the database

create table layar(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), title VARCHAR(30), lat FLOAT(10,6), lng FLOAT(10,6));

2. Add some destinations

insert into layar (id, title, lat, lng) values ('','Location 1', '55.375153', '13.157624');
insert into layar (id, title, lat, lng) values ('','Location 2', '55.374065', '13.158255');
insert into layar (id, title, lat, lng) values ('','Location 3', '55.374943', '13.160877');

All these positions are within a small city in southern Sweden called Trelleborg (Google maps link). So when you do your layer API testing you need to drag the API person to Trelleborg.

The code

The file you are about to create should be on the server and with the name you stated in “POI URL” during the Layar layer setup.

3. Now some PHP

<?php
header('Content-type: application/json');

// Please change these settings!
$config["server_ip"] = “your_server_ip”;
$config["db_user"] = “your_db_user”;
$config["db_password"] = “your_super_password”;
$config["db_sid"] = “your_database_name”;
$config["layer_name"] = “your_layer_name”; // You get/set this when you setup your layer.

// Get parameters from the Layar API.
// Please look at the API documentation for full information on these parameters.
$center_lat = $_GET["lat"];
$center_lng = $_GET["lon"];
$radius = ($_GET["radius"]/1000); // From KM down to meters as this is what we use for our SQL call.
$timestamp = $_GET["timestamp"];
$developerId = $_GET["developerId"];
$developerHash = $_GET["developerHash"];

// Opens a connection to a mySQL server
$connection=mysql_connect ($config["server_ip"], $config["db_user"], $config["db_password"]);

// Set the active mySQL database
$db_selected = mysql_select_db($config["db_sid"], $connection);

// Search the rows in the markers table
// 6357 km at the pole
// 6371 – default
// 6378 KM at the equator

$query = “SELECT id, title, lat, lng, (6378*acos(cos(radians(‘” . mysql_real_escape_string($center_lat) . “‘))*cos(radians(lat))*cos(radians(lng)-radians(‘” . mysql_real_escape_string($center_lng) . “‘))+sin(radians(‘” . mysql_real_escape_string($center_lat) . “‘))*sin(radians(lat)))) AS distance FROM layar WHERE id HAVING distance<’” . mysql_real_escape_string($radius) . “‘ LIMIT 0, 10″;
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);

// If we don’t get any hits lets send back error/nothing.
if (!$result or $num_rows==0)
{
$arr = array(“hotspots”=> “”, “layer”=>$config["layer_name"], “errorString”=>”Sorry, no destinations close to you right now!”, “morePages”=>false, “errorCode”=>21, “nextPageKey”=>null);
echo json_encode($arr);
exit; // Exit as we don’t want to run code below this if error/nothing.
}

// Lets start building valid return.
$returnJSONArray = array(“layer”=>$config["layer_name"], “errorString”=>”ok”, “morePages”=>false, “errorCode”=>0, “nextPageKey”=>null);

while ($row = @mysql_fetch_assoc($result))
{
$returnJSONArray["hotspots"][] = array(
“actions” => array(),
“attribution” => “Teknograd AB”,
“distance” => $row['distance']*1000, // km back to meter!
“id” => $row['id'],
“imageURL” => null,
“lat” => (int) str_replace(“.”, “”, $row['lat']), // API wants clean INT we store in FLOAT.
“lon” => (int) str_replace(“.”, “”, $row['lng']), // API wants clean INT we store in FLOAT.
“line2″ => null,
“line3″ => null,
“line4″ => null,
“title” => $row['title'],
“type” => 0);
}
echo json_encode($returnJSONArray);
?>

Lets sum up

We are done. This is really all you need to get the backend to work.

4. Whats next?

Make sure the PHP code is correct before starting to do test calls through the API test (which is a great tool). Don’t forget to move the API test person to Trelleborg, Sweden.

Any thoughts or ideas in conenction with this please let me know!

What are we using Layar for?

We are using Layar for our open communication platform WAYD. We let users store locations through our free iPhone application WAYD (download from iTunes Store). When a location is stored everybody else can see the photo through Layar. This enables people to experince the same thing as previous people and see what they wrote at that location.

Reblog this post [with Zemanta]

WAYD iPhone application

October 16, 2009

First of, what is the WAYD iPhone application?
- Basically it sends a photo and a text to http://wayd.no. On that site you can, if you want, create a account and forward any messages to Twitter and/or Facebook.

Would you like to try out our WAYD iPhone application please follow these steps.

1. Search for “WAYD” in “App Store” and install.
IMG_0429

2. When you open the app for the first time you will be asked to set your phone number in application preferances.
IMG_0430

3. So you need to close the app again and go into your phone settings and find “WAYD” among your other downloaded application settings.
IMG_0434

4. Add your phone number (please write the number without space and start with 46 in Sweden and 45 in Denmark. Norwegians don’t need to set prefix).

5. Exit settings and start the WAYD app again. Click on the camera icon and take a phone or select one from the camera roll. Fill in some text and when done press “Send”. Your WAYD post will be uploaded to http://wayd.no.

You WAYD!

Reblog this post [with Zemanta]

Flex socket sucks

October 14, 2009

ActionScript
Image via Wikipedia

We needed to build a Flex based FTP upload client. With socket support and the help of ActionScript 3 this should be pretty easy.

However I was very surprised to see that this was not at all easy. Flushing data from the socket is non-blocking. This means that you send the data and don’t get any feedback when the data is done.

The FileStream class however seems to have solved this with OutputProgressEvent. Why not Sockets?

So to build our FTP client we needed to split the data and send it chunk by chunk and loop through it. This is a really bad solution as we need to be absolutely sure that the previous chunk is done before sending the next. This means that that any upload will be extremely slow.

If you read this and feel you have a workaround please share.

BTW: This behavior is reported as a bug at Adobe (read more)

Reblog this post [with Zemanta]

Twitter bot update

October 9, 2009

Robot Attack!
Image by Dan Coulter via Flickr

@bracitat now have 115 real followers after 1329 tweets.

As before (see previous blog) we block spam followers and then follow all persons who are from our target region (Sweden/Norway). As of today we follow 77 people. This means we are down from around 10% to 8,7% in relation to number of tweets and followers. But what is interesting is that the number of people we follow, or what we call valid followers, is now up to nearly 6%.

It also seems that we are getting a larger amount of RT’s. I will get back to the statistics on this in a later post.

Our bot test will continue.

Reblog this post [with Zemanta]

Why a Twitter bot?

September 30, 2009

A couple of weeks ago I created a Twitter bot.

Why?
Well that’s a good question as I really don’t like bots. At least I didn’t until I started seeing the feedback I got on the bot.

What makes your bot tick?
The bot is called @bracitat and it monitors the Swedish word “citat” which would translate to “quote” in English. We also monitor the same word in Norwegian. When the bot sees this word we pull a quote from a database and sends it to the person mentioning the word “quote”.

What makes this so great?
Since we started it we have sent 800 tweets and received over 80 real followers. I try to block spam followers once a day (if I block them they wont show up in my followers list). This would mean that we get around 10% followers i relation to tweets sent. Less then half of these seems to be people from outside Scandinavia (especially Romania which seems to have the word “citat” in their language as well) the rest I set @bracitat to follow. This means that from 800 tweets we get 5% valid followers who enjoy the service.
The feedback is wonderfull! On a daily basis we get tweets from people who loved the quote.
Some feedback

But why?
The reason I made the bot was to create a automatic brand listener. If someone writes “Volvo” (this is just an example, I am in no way affiliated with Volvo) in a tweet your bot can reply with relevant contact information on how to reach a Volvo dealer. This might not be relevant at all. But if the bot can help to direct a customer through to the right contact channels you will get one happy customer.
Soon Twitter will store Geo data and with this information the bot will give you the phone number to the local Volvo dealer.
People react on a obvious bot messages. For this reason the bot will and should reply with different messages as often as possible.
Enhancing our simple bot will make it possible for the web to understand and satisfy the requests of people and send back relevant information.

I still don’t like bots, do we need this on Twitter?
You can always block bots and you should if you feel that they bug you. But bots are part of the future. Google Wave will rock the communication world and one of its main features is the robot interface. The robot interface will interact in your daily communication soon, so whether you like it or not you will talk to a bot within the near future ;-) .

Reblog this post [with Zemanta]

New WAYD logo

June 23, 2009

Leo Utskot at http://www.copyleft.no made two new versions of the WAYD logo.

wayd_logo wayd_logo-white

Thanks Leo :-)

What do you think about them?

Many of our newspaper customers have opened the possibility for comments on their site. The reasons why they do it may vary but I believe it is strategically important for the future. Newspapers who wont listed to their readers and the local community will loose ground faster and harder then the others.

Handling incoming information in a fast and effective way into the editorial department is more important today then ever before. Breaking news will probably not come from the big news agencies!

Most of the newspapers today have some type of communication platform to retrieve feedback from readers. Many newspapers have inefficient solutions where editorial people have to look into one solution for  SMS/MMS, one for email and another for registered analog phone calls and so on!
There are solutions like http://vgnewsportal.com to make all these feedback streams more efficient.

What has this to do with comments?
Comments on a site are in many cases handled by the web content management system or a stand alone system.
Wouldn’t it be better to handle these messages in the same manor and by the same people who handles the other incoming streams?
I think so!

What do you think?
How do you handle comments today?
Is it a good idea to centralize this through the same interface as SMS/MMS and email?

Reblog this post [with Zemanta]
Flight 1549 Crash
Image by Aphony via Flickr

I have been looking into the possibility to monitor Twitter through codewords. Setting up a list of codewords which would be monitored 24/7. Example: Fire, Robbery and so on. The obvious problem with this is that you need to know what to look for and even then you can be far off. If you for example setup some codewords like “plan” and “crash” you wouldn’t get any hits on a story like this:
- Landing on Hudson river with a Boeing 737!

What hit me the other day is that this might be the wrong way around it. Most newspapers today have some type of SMS/MMS channel into the newspaper. Daily you promote your SMS number. Some newspapers do a good job in this, other hide contact information in obscure places.

But you could also promote a hashtag (ex. #2200, #71000). So a person who wants to inform or get in touch with you will add this hashtag to the message.
- Landing on Hudson river with a Boeing 737 #2200!

You can’t own a hashtag. But a number combination or a company name like #endi (El Nuevo Dia), #2200 (VG) or #71000 (Aftonbladet) is so unique you will probably not get to much irrelevant tweets. The hashtag is easy for competitors to monitor! But focusing on that is missing the point.

The hashtag approach in connection with loads of following/followers and maybe a 24/7 codeword monitor will get you the stories real quick.

Reblog this post [with Zemanta]