Facebook's recon team hit the ground in Nigeria in the dead of night, and right away ran into trouble with the law. "What did you bring for me," demanded the first cop they encountered. "We brought ourselves," responded Facebook's Ragavan Srinivasan, an Android program manager, "do you want a hug?" He didn't; he wanted a small bribe as an entry fee. (They refused.) This wasn't business as usual in California, but then again that was the entire reason they had come to Africa.

At Mobile World Congress today, Facebook CEO Mark Zuckerberg announced a new Internet.org innovation lab where developers will be able to test the kinds of challenging connectivity conditions they might expect to find in the developing world–without even leaving California. He was describing something that had its roots in this trip to Africa. Facebook had already conquered America. Now, it wanted to take on the rest of the world–especially the parts where people weren't even online yet. The first step in that journey was to score a phone. Something cheap. Something you couldn't get in the US.

Srinivasan and George Wang, another of Facebook's Android project managers, rose early and headed to an electronics market on the outskirts of Lagos. Called Computer Village, it sprawls across several square blocks just off of Kodesoh Street in Ikeja and is chock full of every type of device imaginable, new and used, genuine and counterfeit, legal and decidedly not.

Music blared from the stalls. Srinivasan and Wang stopped at one of the higher end stores (meaning one with walls and a roof) and haggled their way into a couple of Android handsets. Stepping back out into the scrum, they elbowed their way through the crowd in the street to another stall where they picked up a few SIM cards with what passes for a decent data plan in Lagos–30MB of data.

Back at the hotel, they fired up their new phones. Both had old versions of Facebook pre-installed, which they began updating along with some other apps. In 40 minutes, they'd burned through their monthly allotment of data. That was a problem. It was far from the only one.

For many people in the developing world, Facebook is the Internet. And while that may be somewhat true in America too, we Yanks can at least pull up the world's leading social network on desktops and iPhones and Galaxy S4s with robust Internet connections, gorgeous screens and easy access to a reliable power grid. Meanwhile, in Africa and Asia and South America where Facebook is trying attract another 5 Billion users, that technological sophistication is far from given. Facebook faces massive hurdles there that are just unknown here.

As Facebook looked out across the globe it wanted to conquer, it saw a mish-mash of unreliable networks, low resolution screens, and shitty processors. There were all manner of various flavor of Android, problems with local language support, confusion over pricing, and unreliable or non-existent power grids. There's the question of how you make social connections between people with no address books, no email address, no university affiliation, and who are perhaps the very first person in their village to sign up for Facebook. The challenges weren't just difficult, they were epic.

"When you look back at Facebook's Web roots, we had an incredible amount of infrastructure," explains Srinivasan. That infrastructure doesn't really exist where the world is coming online via mobile networks: typically on feature phone or cheap Android handsets. Instead of broadband LTE, these phones often only have tenuous connections to 2.5G towers. They may only have the ability to charge up once a week, when a truck rolls through town with portable batteries. Data plans can often be eaten up by a single shared photo. Local language support is often non existent. If Facebook wants those users–and it does–it has to give them an entirely other experience than the one it delivers to North America.

Make It Snappy ————–

While Facebook needed a new plan, it didn't have to completely start from scratch. Thanks to an acquisition in 2011, Facebook already had a powerful asset in its possession capable of delivering a robust experience on a subpar device: Snaptu.

Snaptu was a tool designed to deliver smartphone-style Internet apps to old-fashioned cell phones. It launched in 2007, before the first iPhone, with the goal of trying to solve application fragmentation issues across a landscape of thousands of feature phones. It did this by essentially offloading all the processing functions to its own servers on the back end, and delivering images or text on demand–you might press the 1 key to view a new shared photo or message, for example. Facebook bought it in 2011, and brought its founder Ran Makavy from Tel Aviv to Menlo Park. Makavy, in turn, brought Snaptu's immense know-how for working with all kinds of handsets and mobile networks. Today, the service is called Facebook for Everyphone, or FB4E, and it has more than 100 million active users. "What we try to do is to minimize data usage and increase speed," explains Makavy.

Much of what Facebook learned with FB4E turned out to be directly applicable to Android devices it was now starting to see in the developing world–they share many of the fragmentation issues and hardware limitations (like small low resolution screens), and are running on the same networks Facebook already knew from its FB4E program. And in fact, it already even knows many of these customers from FB4E. As Makavy describes it, not only does FB4E not mind churn, it embraces it. They want the FB4E users to move on to smartphones, where they will have a better experience. "If we do an amazing job, you're probably going to buy an Android."

Snaptu founder Ran Makavy now runs FB4E, letting feature phone users use Facebook

The problem was, when those Android users were coming online, Facebook didn't have a clear idea of the conditions they could expect. "That inspired us to go into some of these markets and understand the steps for a brand new user to get the phone, get the SIM card, sign up for a data plan, and then actually sign up for Facebook," says Srinivasan.

But because it wasn't practical to send every engineer to every market, the company recreated those experiences inside its Menlo Park campus–this is the genesis of the Internet.org innovation lab. In essence, it took one of the most high-tech locations on earth, and turned it into a rural village without 3G service or electricity. It tapped into its deep relationships with handset makers, chip manufacturers, service providers, and network operators to understand the conditions they saw globally, and built a lab called that let its engineers select a setting for, say, Nairobi, and instantly connect to a simulation of an over-the-air network there.

Facebook turned to its Internet.org partner Ericsson to help understand what those networks look like. Ericsson is a back-end telecom monster; it provides many of the network services that mobile operators use throughout most of the world. It's preconfigured to replicate the conditions of, say, an overcrowded LTE network in Jakarta or a rural 2.5G network in Kenya.

Facebook and Ericsson took that lab out on the road earlier this year, when it sponsored the first Internet.org hackathon, and it's planning to invite developers in later this year with the Internet.org Innovation lab hosted at its headquarters in Menlo Park.

Some of the many handsets found at Facebook.

The other thing it needed to understand, above and beyond the networks, were the devices themselves. Facebook bought up a slew of obscure handsets from Amazon–devices running older versions of Android, feature phones, all sorts of crazy devices that you just don't see here in the United States. It began handing these out to it engineers, and one point, even mulled over taking away their iPhones. That didn't fly.

"Our initial plan was to say you're not going to use your primary phone, but this was going to be over Christmas and we realized that wasn't going to make us very popular," laughs Srinivasan. "So what we did instead was ask them to use them and come back and file reports."

They found all sorts of ways to deliver a lower-bandwidth experience in the main app. When possible, Facebook's mobile app offloads code fetching to WiFi. It began delivering different resolution images based on the device–there's no point in serving up a high resolution image to a low resolution screen. It went to a different image format as well, WebP, a newer file type that lets developers use smaller images. "What we've seen is 20- to 30-percent reduction in bytes for the same quality of images," says Wang. The app also began doing things like letting users know it was seeing network problems, and offering them the option of trying again–instead of just continually trying to communicate with a tower and sucking out precious battery life. That's vitally important when you're serving areas that are often off the grid and have to pay per juice up.

What's a Megabyte? ——————

In addition to all the technical hurdles, Facebook realized it had another problem with the transition to smartphones: most people are completely unfamiliar with the terms of a data plan, which are typically sold in units of megabytes. For someone who has never sent a camera phone image before, or downloaded a song, or attached a file to an email–or for that matter sent an email–megabytes and gigabyte style plans are very literally a foreign concept. Why would you even want a data plan if you'd never used the Internet?

Facebook's Chris Daniels says you have to charge in units people can understand.

To get around this Facebook began making a pitch to carriers to convince them to offer Facebook in more digestible units. In India, for example, Airtel charges 1 rupee per day for Facebook access. You can do whatever you want with that–upload photos, watch your friends videos, go nuts–but just for 24 hours.

"A day of Facebook is a unit people can understand,"explains Chris Daniels, Facebook's VP of business development. "A megabyte? I don't even really understand what that is. But a day of Facebook? How that pricing is packaged is very important. It helps more people come online to speak in units they can understand."

There's another practical reason behind this too: daily plans are already the norm in countries where there is no consumer credit system. Plans are often paid for in cash at local shops on an as-needed basis. If you want to use the Internet that day – maybe you want to check the weather or get in touch with a family member overseas – you buy a day's worth of access, and get a code to input to go online.

Some carriers even run a promotion called zero.facebook: free or very low price access to Facebook, often only for a limited time. This grew out of of a program it launched in 2010 that let people access a text-only version of the site at 0.facebook.com. Today, it's a partner program, and will do things like give people a month of free Facebook access with a new phone.

"What carriers have found is that [people] understand what Facebook is, even when they don't understand what the Internet is," says Daniels. "When a carrier is thinking 'hey I want to get more data users,' they think that Facebook is an onramp to the Internet. So they offer free Facebook to get people used to using the Internet and understudying what it is, and then they can start to think about opening up users to other experiences."

Zuckerberg echoed that sentiment today at Mobile World Congress, describing a situation that's good for both Internet companies and carriers themselves, "putting in an onramp is better for the Internet and their models," he said. In essence, it's like a free hit of an Internet crack pipe. Try it and you're going to like it, and will be willing to pay for it.

Who's Your Buddy? —————–

Carrier deals also explain how it helps find friends in the absence of established networks like it has online.

"When you sign up for Facebook, the single most important thing we can do is connect you with your friends," says Alex Schultz who runs growth marketing for the company. "If we can just get you a friend's face in the first few minutes you're on the site, you're hooked."

But that's easier said than done. It needs your profile picture, which you have to upload–and it also needs to be able to suck up your contacts and look for matches. If it doesn't find any, "Facebook's useless, and you leave," says Shultz.

Oddly, it's okay if you do that. They key is to get you to come back. Let's say one of your friends finally joins, he may add you, because you're already in the system. Then another joins, and another. And every time this happens, you get a notification on your phone, and your news feed begins to fill up with things you care about.

But to do this, it has to be able to send you those notification. And it needs to make sure that notification is delivered. That's easily accomplished on the Web, where the bulk of its notifications are routed via three major email providers–Google, Yahoo and Microsoft. But it's much harder on mobile.

Alex Schultz just wants you to see a friendly face.

Facebook can't pay for all those notifications to be delivered via SMS, because it would simply be cost-prohibitive. Which meant it had to go out and do deals with 300 plus different operators to deliver Facebook's notifications for free, via SMPP. The pitch is used is that people would in turn use Facebook more and thus more data. Carriers had already seen evidence of this with Snaptu, and Facebook could point to numbers showing a big uptick in responses from customers to the messages it sent out, and more users using their data plans. For the most part, it worked.

"What we get is more retention," says Schultz, "what they get is more data."

What Facebook also gets more data via retention in the form of more people doing more things it can track. More people equals a bigger social graph, and more knowledge about the people within and how they are connected, where they live, where they've been, what they love. It gets to know things about whole world and, presumably, one day down the line serve the world an ad.

But that may take some time. At Mobile World Congress, Zuckerberg played down the notion that it was anywhere close to being able to actually make any money off of people just now coming online in the developing world, "I think we will lose money on this for a while."

All photos: Josh Valcarcel/WIRED

Updated 02/22/2014 07:51 PM to correct an error regarding payment to officer on arrival in Nigeria.