0% found this document useful (0 votes)
5 views25 pages

Introducing Social Graph - Part 2

Uploaded by

keerthi Raj.S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views25 pages

Introducing Social Graph - Part 2

Uploaded by

keerthi Raj.S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

INTRODUCING SOCIAL GRAPH

Social Graph
• A social graph is created through this widespread interaction and
exchange of information on social media.
• A social graph is a massive network that illustrates the relations
between individuals and information on the internet
• User graph: This is a network that shows the relationships between
users or individuals connected to each other.
• Content graph: The relationship existing between different types of
content (text, images, videos, or multimedia) uploaded on social
media
• Interest graph: The interest graph takes the original graphs a step
further, where individuals on the social media or the internet are
not related based on their mere links, like being added as a friend
or followed on Twitter, but on their mutual interests.
SOCIAL WEB ALONG WITH DATA
MINING
SOCIAL WEB ALONG WITH DATA MINING, ANALYSIS,
AND VISUALIZATION TECHNIQUES TO EXPLORE DATA
• Who knows whom, and which people are common to their social networks?
• How frequently are particular people communicating with one another?
• Which social network connections generate the most value for a particular niche?
• How does geography affect your social connections in an online world?
• Who are the most influential/popular people in a social network?
• What are people chatting about (and is it valuable)?
• What are people interested in based upon the human language that they use in a
digital world?
The answers to these basic kinds of questions often yield valuable insights and
present (sometimes lucrative) opportunities for entrepreneurs, social scientists
What is an API?
• API is the acronym for Application Programming Interface
• A software intermediary that allows two applications to talk to
each other.
• When you use an application on your mobile phone, the
application connects to the Internet and sends data to a server.
• The server then retrieves that data, interprets it, performs the
necessary actions and sends it back to your phone
EG: Searching Flights Online
• If you are using an online travel service, Expedia, interacts with
the airline’s API.
• The API is the interface with which the online travel service
interacts to get information from the airline’s database to book
seats, baggage options, etc.
• The API then takes the airline’s response to your request and
delivers it right back to the online travel service
• The online travel service then shows you the most updated,
relevant information.
API
Application Programming Interface
• A set of instructions and standards to access a web based software
application.
• APIs allow users to send a request for a particular resource, such as
Facebook or Twitter, and receive some data in response.
• It is worth noting that all API providers fix some limitations on the quantity
or type of data which users can obtain
• Social media also started creating APIs to share their data with third-party
application developers
• The nature of all social media is different, so are their APIs.
Different types of API
• Two types of API are
• RESTful API
• Stream API

RESTful API
• The most common type of API that most social media provides.
• The information from a REST API is static and is from historical data.
• The back history of data can vary from platform to platform.
• Facebook calls its REST API service Graph API.
RESTful API
• REST stands for Representational State Transfer and it relies on the HTTP
protocol for data transfer between machines.
• Web APIs that adhere to the REST architectural constraints are called
RESTful APIs
• It has been created to simplify the transfer of data between machines
• Two of the most important uses of RESTful services are:

• GET: Procedure to receive data from a distant machine


• POST: Procedure to write data to a distant machine
Stream API

• Stream API is used when the requirement is to collect data in real time,
instead of backdated from the platform.
• The Stream API of Twitter is widely used to collect real-time data from Twitter.
Advantages of social media APIs
• Social data: APIs allow you to extract valuable data around Social Media
users and content that is used for behavioral analysis and user insights.
• App development: Thousands of software and applications have been built
using Social Media APIs that provide additional services on top of Social
Media platforms.
• Marketing: Social media APIs are useful in automating marketing activities
such as social media marketing by posting on platforms. It also helps in
enriching marketing data through Social Data acquired about customers.
Limitations of social media APIs
• Rate limits:
• Social media companies need to take into account the amount of data that
enters or leaves their systems.
• The amount of data and the speed of receiving are clearly stated by most
social media platforms. This should be included in the extraction strategy.
• API changes:
• Social media platforms are free to change or stop their API services. Such
kinds of change or stoppage could severely impact development or
analytics strategies.
• The only advice in such situations is to be prepared for it and have flexible
systems to be able to adapt to the changes.
• Legal:
• This challenge is mainly in the use cases around social media APIs.
• The rules and regulations for social media platforms are strict about the
type of usage of its data and services.
• Any use of data from APIs that doesn’t conform to the stipulated regulations
risks legal implications.
Connecting Principles of APIs
• Connecting to social media platforms and using their API data services require a
few steps to be configured before usage. There are nuanced differences
between different platforms, but the following are the general steps that are
applicable to almost all:
STEP 1:
• APP registration: Almost every social media platform needs you to register your
application on their website. It involves entering personal information and the
objectives in using their API services. This step results in the generation of
certain keys, which are called authentication and consumer keys.
STEP 2:
• Authentication: Use the consumer keys (also called authentication keys)
generated from the previous step to authenticate your application.
STEP 3:
• API endpoint hunting:
• When an API interacts with another system, the touchpoints of this
communication are considered endpoints.
• An endpoint can include a URL of a server or service.
• Each endpoint is the location from which APIs can access the resources
they need to carry out their function.
• The API endpoints will be different for each provider, so it is necessary
to read the provided documentation to identify which end points best
correspond to your needs.
• EG:
• The Twitter REST API allows clients to retrieve a sample of tweets based on
search criteria
• The endpoint URL for this resource is
https://api.twitter.com/1.1/search/tweets.json
INTRODUCTION TO
AUTHENTICATION
TECHNIQUES
What is OAuth?
• OAuth is an authorization protocol that allows users to share data
with an application without sharing the password.
• It is a way to obtain a secure authorization scheme based on a
token-based authorization mechanism.
• There are two API authentication models using OAuth:
• User authentication
• Application authentication
User authentication

❑ This is the most common form of resource authentication implementation

❑ The signed request both identifies an application's identity in addition to


the identity accompanying granted permissions of the end user making
API calls on behalf of, represented by the user's access token.
Application authentication

Application authentication is a form of authentication where the


application makes API requests on its own behalf, without a user
context.

For the purposes of social media analysis, we will use in most


cases application authentication by creating an application on
each social media platform that will query the related API.
Steps that are required to put in place
a client with OAuth authorization
1. Creating a user/developer account: First, you have to register a user/developer
account and provide personal information such as a valid email address, name,
surname, country, and in many cases a valid telephone number (the verification
process is done by sending you a text message with a code)
2. Creating an application: Once you create your account, you will have access to a
dashboard, called a developer console. It provides all the functionalities to
manage your developer account, create and delete applications, or monitor your
quota. In order to obtain access credentials you will have to create your first
application via this interface.
3. Obtaining access tokens: Then, you generate access tokens for your application
and save them in a safe place. They will be used in your code to create an Oauth
connection to the API
4. Authorizing HTTP requests (optional): Some APIs require HTTP request
authorization, which means that a request has to contain an additional
authorization header that provides the server with information about the
identity of the application and permission scope.
5. Setting up permission scopes (optional): Some APIs have the notion of
multilevel permissions. In that case when you generate your API key you need
to specify the scope for the key. Scope here refers to a set of allowed actions.
Therefore, when an application attempts an action that is out of its scope, it
will be refused. This is designed as an additional security layer.
Ideally one should use multiple API keys, each with restricted scopes, so
that in the scenario where your API key is hijacked, due to the restrictions in
its scope the level of potential harm is restricted.
6. Connecting to the API using obtained access tokens: When all the preceding
steps are configured, you can make requests using your access tokens. Now,
the only limitation is the request quota, which depends on each platform.
Parsing API outputs - Twitter
• How to connect to different social networks and how to retrieve sample
data
Twitter
• Twitter proposes three main APIs:
• REST API
• Streaming API
• Ads API

• The first two APIs provide on-demand or stream data respectively.


Creating application
• In order to obtain credentials to be able to collect data from Twitter. There are a few
simple steps to perform
1. Create a Twitter account or use your existing one.
2. Go to https://aps.twitter.com/ and log in with your account.
3. Click on Create your app and submit your phone number. A valid phone number is
required for the verification process. You can use your mobile phone number for
one account only.
4. Fill the form, agree to the terms and conditions, and create your Twitter application.
5. Go to the Keys and Access Tokens tab, save your API key, and API secret and then
click on Create my access token to obtain the Access token and Access token secret.
These four elements will be required to establish a connection with the API.
Selecting the endpoint
• An endpoint indicates where a particular resource can be accessed.
• It is represented by an URL that contains the name of the action
• The Twitter REST API allows clients to retrieve a sample of tweets based on search
criteria.
• The search request is made up of a Boolean query with some additional optional
parameters (to, from, list, url, filter)
• The endpoint URL for this resource is stored in a url variable:
url_rest=https://api.twitter.com/1.1/search/tweets.json
• The endpoint URL for the Streaming API that returns a random sample stream of
statuses:
url_streaming = https://stream.twitter.com/1.1/statuses/sample.json
Both variables are used to retrieve and parse the data

You might also like