38
Part 3: Online Social Networks 1

Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Part 3: Online Social Networks

1

Page 2: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Today's plan

• Project 2 Questions?

2

Page 3: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Social networking services

• Social communities– Bebo, MySpace, Facebook, etc.

• Content sharing– YouTube, Flickr, MSN Soapbox, etc.

• Corporate– LinkedIn, Plaxo, etc.

• Portals– MSN, Yahoo 360, etc.

• Recommendation engines– Last.fm, StumbleUpon, Digg, Me.dium, etc.

• Bookmarking/Tagging– Del.icio.us , CiteUlike, Furl, etc.

• Discussion groups– Blogs, forums, chat, messaging, Live QnA, etc.

• Mobile social networks– Vipera, Nokia “MOSH”, etc.

• Virtual worlds– Second life

3

Page 4: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Social Network Sites: History

[Boyd et al., 2007]

SixDegrees.com the first recognizable OSN

Profiles and lists of friends

Combined existing features!

Failed - Nothing to do after accepting friend requests.

OSN wave after 2001

Friendster:

Technical and social difficulties with scale!

“Fakesters” diluted the community

MySpace:

Capitalized on Friendster’s problems

Bands and fans

Allowed personalization of profiles

Facebook:

Growth: Harvard-only => University-only => high schools & professionals => everyone

Introduced applications (provided APIs) 4

Page 5: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Social networking services

Source: Bebo, Social Media – ‘getting your message across’

Shift in online communities

OSNs are organized around people

“Egocentric” networks

WEB: world composed of groups

OSNs: world composed of networks

5

Page 6: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

What do social networks enable?

Leveraging the “community”

in traditional applications

• Content/information sharing

• Search

• Information management

• Recommendations

• Advertisements

6

Page 7: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

What is social media marketing anyway?

7

• Growing out of search marketing, and public relations before that

• Social media marketing is any way you can get attention for your message using people connected to the Internet

People + message + Internet = social media marketing

Page 8: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Content-based social media marketing

8

• Focuses on the content to be posted and passed around: blogs, videos, photos, news stories, podcasts

• Or bookmarks to the content

• Feeds viral marketing

Content sites

Bookmarking sites

Page 9: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Personality-based social media marketing

9

• Consumer companies create character profiles, but may not be the best marketing for IT companies

• IT consultants create professional profiles

Page 10: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Interest-based social media marketing

10

• Communities form around topics of interest, such as message boards and specialty search engines

IT marketers must get into these

conversations

Maybe social bookmarking sites fit into this

category, too

Page 11: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Fantasy-based social media marketing

11

• Virtual worlds, inhabited by avatars, allow fantasy lives that marketers wish to be part of—Apple, IBM, and other companies already play

• Kids have their worlds, too, but IT marketers can safely ignore them

Page 12: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Social media marketing can be planned

12

• Choose interesting topics for your stories—just like good old public relations

• Use good titles and descriptions—just like search marketing

• Make it easy to bookmark, unless you think that’s cheesy

<title>

Page 13: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Even virtual worlds get marketing plans

13

• IBM has over 4,000 employees who participate in over 30 Virtual Worlds

• IBM has more than 30 virtual islands in Second Life for developer support, client meetings, and more

Orientation

Area and Map

of part of IBM’s

presence in

Second Life

Page 14: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Plan for next two weeks

• Today:– Facebook platform overview

– PHP language

• Next Tuesday (Lecture)– PHP (continued), Ziran Chen leading

• Next Thursday (Lab session)– Project 2 presentations

– Facebook API, "hello world"

– Assignment 4: First Facebook App14

Page 15: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

What is Facebook

• More than 1Billion users worldwide

• Gallery, Profile Management,

Collaboration, Notes, Ratings, Discussion Boards, Video all in one place

• You don’t need to pay anything to access it

• Social Network

15

Page 16: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Benefits of developing on FB Platform

• User management is done by FB

• Harvest social relationships

• Viral marketing

• Easy to develop, promote and monetize

• Bring an existing app and brand into FB

• Support for different languages

16

Page 17: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Seriously, what can I develop?

• Imagination is the limit

• Games

• Dumb entertaining apps

• Content sharing apps

• Business apps

• Social network aggregator and mash-ups

17

Page 18: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Lets Start!

18

Page 19: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

How an app works

19

Page 20: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Facebook Platform

• Allows third parties to develop web or desktop applications that– leverage user data and Facebook’s social graph

• e.g. name, networks, photos, friends, marketplace, etc

– deeply integrate into the Facebook ecosystem• e.g. profile real estate, mini-feed, look and feel, etc

• Frontend Integration (UI)– Reusing Facebook’s controls and styles

• Backend Integration (Data)– Access to user data and settings as well as scalable

data store

20

Page 21: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Frontend Platform

• Markup (FBML) – extension of HTML

– Stands for Facebook Markup Language

– Improves usability by allowing third-party applications to leverage existing Facebook UI controls

• dashboard, invite users, comments, forms, type-ahead, etc

– Adheres to each user’s privacy settings automatically

• Scripting (FBJS)

– Stands for Facebook JavaScript

– Facilitates “Javascript” functionality in a safe context

– Includes native support for Ajax and Animation libraries

21

Page 22: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Backend Platform

Query (FQL)Stands for Facebook Query LanguageOffers SQL-like interface to get/set user data

Interface (API)Offers REST-like interface to get/set user dataClient (wrapper) libraries exist in 17+ programming languagesPHP, Ruby, C#, Java, Perl, Python, Lisp, etcEncapsulate common, mundane and generally difficult to “get right”

tasks such as authentication, encryption, transformation, etc

Data StoreFacebook offers applications free (though capped) data store

that is highly scalable (i.e. optimized distributed tables)

22

Page 23: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

User makes request for an

application hosted page

Facebooksends request to application

Application renders and

returns response to Facebook

Facebookrenders (parses)

response from application

Facebookreturns

requested page to User

FB Platform Architecture

Your code processes

form request using

PHP and generates

FBML pages

23

Page 24: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

PHP Syntax

• <?php/* code */

?>

Example (http://dutch.mathcs.emory.edu/~eugene/lab9/hello.php )<html>

<body>

<?phpecho "Hello World";

?>

</body></html>

24

Page 25: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Intro to PHP

• PHP stands for PHP: Hypertext Preprocessor

– is a widely-used, open source scripting language

– scripts are executed on the server

• PHP files can contain text, HTML, JavaScript code, and PHP code

– code is executed on the server, and the result is returned to the browser as plain HTML

– PHP files have a default file extension of ".php"

25

Page 26: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

What Can PHP Do?

• generate dynamic page content

• create, open, read, write, and close files on the server

• collect form data

• send and receive cookies

• add, delete, modify data in your database

• restrict users to access some pages on your website

• encrypt data

26

Page 27: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

27

PHP Variables

• A variable is created the moment you first assign a value to it:– $txt="Hello world!";

• PHP automatically converts the variable to the correct data type, depending on its value.

27

<?php

$x=5;

$y=6;

$z=$x+$y;

echo $z;

?>

Page 28: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Scope

• Four variable scopes:

– local

– global

– static

– parameter

28

<?php

$x=5; // global scope

function myTest()

{

echo $x; // local scope

}

myTest();

?>

Page 29: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Global Scope

• A variable that is defined outside of any function, has a global scope.

• Global variables can be accessed from any part of the script, EXCEPT from within a function.

• To access a global variable from within a function, use the globalkeyword:

29

<?php

$x=5; // global scope

$y=10; // global scope

function myTest()

{

global $x,$y;

$y=$x+$y;

}

myTest();

echo $y; // outputs 15

?>

Page 30: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

PHP Strings

• Very similar to JavaScript

• http://www.w3schools.com/php/php_string.asp

30

Page 31: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Control Flow

• if statement - executes some code only if a specified condition is true

• if...else statement - executes some code if a condition is true and another code if the condition is false

• if...else if....else statement - selects one of several blocks of code to be executed

• switch statement - selects one of many blocks of code to be executed

• http://www.w3schools.com/php/php_if_else.asp

31

Page 32: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

32 CS190: Web Science and Technology, 2010

PHP Arrays

• <?php$cars=array("Volvo","BMW","Toyota");echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";

?>

• http://www.w3schools.com/php/php_arrays.asp

32

Page 33: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

33 CS190: Web Science and Technology, 2010

PHP Loops

<?php

$cars=array("Volvo","BMW","Toyota");

$arrlength=count($cars);

for($x=0;$x<$arrlength;$x++)

{

echo $cars[$x];

echo "<br>";

}

?> 33

Page 34: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Associative Arrays

• Associative arrays are arrays that use named keys that you assign to them.

– $age['Peter']="35";$age['Ben']="37";$age['Joe']="43";

34

Page 35: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Loop through Associative Arrays

$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");

foreach($age as $x => $x_value){echo "Key=" . $x . ", Value=" . $x_value;echo "<br>";}

?>

35

Page 36: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

PHP Functions

• http://www.w3schools.com/php/php_functions.asp

36

Page 37: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

PHP Forms

• <html><body>

Welcome <?php echo $_POST["fname"]; ?>!<br>You are <?php echo $_POST["age"]; ?> years old.

</body></html>

• http://www.w3schools.com/php/php_forms.asp

37

Page 38: Part 3: Online Social Networks - Emory Universityeugene/cs190/lectures/march-21-PHP.pdf · Facebook Platform •Allows third parties to develop web or desktop applications that –leverage

Exercise

• Re-implement the JavaScript calculator app in PHP

38