Showing posts with label Web Services. Show all posts
Showing posts with label Web Services. Show all posts

Sunday 8 December 2019

Swagger - REST API documentation tool

Swagger - REST API documentation tool


Question: What is swagger?
It is REST API documentation tool which is used to list the APIs and view the request and response.
In this, we need to add some annotations in your functions and then it will automatically generate a beautiful and user-friendly documentation for your APIs.



Question: Where it is used?
Whenever we develop an android, IOS (Apple) application, we need to create an APIs for them.

To check the API details (URL, Request, response), we use Swagger.


Question: Who is using swagger?
Backend Developer: developer used it while creating Or updating an API.
Team Leader: As it give List of APIs with request and response. Team leader used it review the APIs.
Android/IOS Developer: While integrating the APIs, Its quite help the developer because they can check the response of APIs with different request.


Question: What are benefits of swagger?
  1. Its give list of APIs with short description.
  2. Its give the Request and Response of API.
  3. We can test the response of API with different request.
  4. We need to integrate in application first time, after the we need to add some annotations in functions/APIs.
  5. Can be integrate in Core PHP or Framework.
  6. We need not to list and details of apis manually.



Question: What is Swagger Editor?
The Swagger Editor is the tool for quickly getting started with the Swagger Specification.
Create new APIs OR update existing ones in a powerful Editor which visually renders your Swagger definition and provides real time error-feedback.
http://editor.swagger.io/#/


Question: Give a Demo URL?
http://petstore.swagger.io/


Question: From where i can download?
http://swagger.io/docs/#swagger-ui-documentation-29


Question: How to Add API in swagger?
Add Following code before the class declaration
/**
 * @SWG\Resource(
 *     apiVersion="1.0",
 *     swaggerVersion="1.2",
 *     description="Search users"
 * )
 */



Question: How to add new Operation for an API?
Add Following code before the method declaration
    /**
     * @SWG\Api(
     *     path="/search",
     *     @SWG\Operation(
     *         method="POST",
     *         summary="Get users near your location",
     *         type="Users list",
     *         @SWG\Parameters(
     *             @SWG\Parameter(
     *                 name="interests",
     *                 paramType="form",
     *                 description="comma seperated looking for",
     *                 required=false,
     *                 type="string",
     *                 minimum="1.0"
     *             ),
     *             @SWG\Parameter(
     *                 name="page",
     *                 paramType="form",
     *                 description="page number",
     *                 required=true,
     *                 type="string",
     *                 minimum="1.0"
     *             ),
     *         ),
     *         @SWG\ResponseMessage(code=400, message="Invalid Data")
     *     )
     * )
     */



Saturday 22 June 2019

How to create an RSS feed from URLs

How to create an RSS feed from URLs

Question: What is full form of RSS?
Rich Site Summary
Its also known as Really Simple Syndication.


Question: What is RSS feed?
It is standard web feed formats to publish the updated information of blog OR website.


Question: What is file extension of RSS Feed?
.xml or .rss


Question: Give a Sample of RSS Feeds?
Start the XML with following code.

<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0">
    <channel>
 <title>Web Technology experts Notes</title>
  <link></link>http://web-technology-experts-notes.in
  <description>We are Web Technology Experts Team who provide you Important information on Web Development</description>
        <item><title>How to create folder with extension like .EBextensions</title> <description>Suppose you want to create folder with name ".EBextensions" Create folder with name ".EBextensions." Press enter You will see "." will disapper automatically from end of string Folder with name ".EBextensions" created successfully.</description><link></link>http://www.web-technology-experts-notes.in/2016/12/how-to-create-folder-with-extension-like-ebextensions.html<pubdate>Tue, 21 Jun 2016 15:36:00 +0000</pubdate><media:thumbnail height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWxGQGHkE2lgyXWpEN-LW9mN1MrHB2ldKSvZX-Xn2ZlAh2Zqv33Saw1_sjYdq7i0N4XPzQ6ufeh8JXw6h2ER9sFqLYyXWMUNcJU7suHXO3bgb7EwMdCaRj7yn-hMVfw5VncU7H3gkryBQ1/s72-c/How+to+create+folder+with+extension.png" width="72" xmlns:media="http://search.yahoo.com/mrss/"></media:thumbnail></item>
        <item><title>FCM push notification example</title> <description>Question: What is FCM Messages? Full form of FCM is Firebase Cloud Messaging. FCM is a cross-platform messaging solution that lets you reliably deliver messages to android and IOS devices at no cost. </description><link></link>http://www.web-technology-experts-notes.in/2016/12/fcm-push-notification-example.html<pubdate>Tue, 21 Jun 2016 20:36:00 +0000</pubdate><media:thumbnail height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJjl1lCoOWux0EG3hYYW1-rJqB-3iJsLaqIK-zOTjD_2Z_sq9v29LsVY9iC3lfu-6LZLD2TNQOahaajIsOP2y-HSQRGhUoe18L5LnJBHTU0ekF_6nVQMwSrYrkaeAJHYhFFkcds6FHEb6m/s72-c/FCM+push+notification+example.png" width="72" xmlns:media="http://search.yahoo.com/mrss/"></media:thumbnail></item>
        <item><title>What are special characters? and how to remove special characters?</title> <description>Question: What are special characters? Special characters are selected punctuation characters present on standard US keyboard. Question: Provide list of special characters?</description><link></link>http://www.web-technology-experts-notes.in/2016/12/what-are-special-characters-and-how-to-remove-special-characters.html<pubdate>Wed, 22 Jun 2016 01:36:00 +0000</pubdate><media:thumbnail height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJjl1lCoOWux0EG3hYYW1-rJqB-3iJsLaqIK-zOTjD_2Z_sq9v29LsVY9iC3lfu-6LZLD2TNQOahaajIsOP2y-HSQRGhUoe18L5LnJBHTU0ekF_6nVQMwSrYrkaeAJHYhFFkcds6FHEb6m/s72-c/FCM+push+notification+example.png" width="72" xmlns:media="http://search.yahoo.com/mrss/"></media:thumbnail></item>
        <item><title>Node JS tutorial for beginner</title> <description>Question: What is NodeJS Node.js is a platform built for fast and scalable network applications. It uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.</description><link></link>http://www.example.com/url4http://www.web-technology-experts-notes.in/2016/12/node-js-tutorial-for-beginner.html<pubdate>Wed, 22 Jun 2016 06:36:00 +0000</pubdate><media:thumbnail height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7anpECNis2R4U7MyWdWUbi9ygJyKA211ydgESbcWUPGgG3acZwMO4vAKe5MxE53DkFdTOMVPVe8AH76piiHPtCo2YmgVrbI4cabzc7lX1slYKhMOHNDi1oWtvTI4B6bz6qsXQVh-sJL-f/s72-c/What+are+special+characters+and+how+to+remove+special+characters.png" width="72" xmlns:media="http://search.yahoo.com/mrss/"></media:thumbnail></item>
    </channel>
</rss>
Question: Create a script for?
Question: From where I can validate the RSS Feed URL?
https://validator.w3.org/feed/


Question: From where I can validate the RSS Feed Data?
https://validator.w3.org/feed/#validate_by_input


Question: Give a script to generate rss feeds from URL?


$urls= array(
    'http://www.web-technology-experts-notes.in/2016/12/how-to-create-folder-with-extension-like-ebextensions.html',
    'http://www.web-technology-experts-notes.in/2016/12/fcm-push-notification-example.html',
    'http://www.web-technology-experts-notes.in/2016/12/what-are-special-characters-and-how-to-remove-special-characters.html',
    'http://www.web-technology-experts-notes.in/2016/12/node-js-tutorial-for-beginner.html',
    );

$dateTime=strtotime('Tue, 21 Jun 2016 10:36:00 +0000');
$siteMapXml = '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0"><channel>';

//Uncomment the below code to enable download
/*header("Content-type: application/xml");
header("Content-Disposition: attachment; filename=rss.xml");
header("Pragma: no-cache");
header("Expires: 0");*/
$siteMapXml.=' <title>Web Technology experts Notes</title>
  <link></link>http://web-technology-experts-notes.in
  <description>We are Web Technology Experts Team who provide you Important information on Web Development</description>';
foreach($urls as $url){    
    $dateTime+=(3600*5);
    $dateString=date('D, j M Y H:i:s +0000',$dateTime);
     $siteMapXml.="<item><title>Page Title</title> <description>Page Description</description><link></link>{$url}<pubdate>{$dateString}</pubdate><media:thumbnail height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWxGQGHkE2lgyXWpEN-LW9mN1MrHB2ldKSvZX-Xn2ZlAh2Zqv33Saw1_sjYdq7i0N4XPzQ6ufeh8JXw6h2ER9sFqLYyXWMUNcJU7suHXO3bgb7EwMdCaRj7yn-hMVfw5VncU7H3gkryBQ1/s72-c/How+to+create+folder+with+extension.png" width="72" xmlns:media="http://search.yahoo.com/mrss/"></media:thumbnail></item>";   
}
echo $siteMapXml.='</channel></rss>';


Question: Give the Sample URL of RSS
Download Sample RSS


Tuesday 24 April 2018

Agora.io WebRTC Basic Understanding


Question: What is Agora Recording Overview?
The Agora Recording SDK is an add-on to record and save voice calls, video calls and interactive broadcasts in server.

Support on below and above versions.
Agora Native SDK version 1.7.0
Agora Web SDK version 1.12.0
Support for CentOS x64 version 6.5 or later and Ubuntu x64 version 12.04 or later.


Question: What are benefits of using Agora Recording?
  1. High-quality recordings for Voice and video.
  2. Single OR Mix audio/video
  3. Raw data of Audio/Photo
  4. Screen Capture
  5. Customized



Question: What services does Agora CaaS provide?
Video/Audio SDKs: APIs for Real-time Audio and Video Communications with one-to-one and one-two-many.
A voice group can be a maximum of 10, 000 people online at the same time;
a video group supports up to seven people online at the same time.

Agora Cloud: We have deployed around 100 data centers in four continents, including thousands of servers.

Real-time Audio and Video Reports: tell you how many active users are using the call service, call duration, call success rate, ratio of low-quality contacts with cause analysis, and so on. In addition, distribution reports show the geographic distribution of users, of network conditions and users, and of time spent on the network. To help with operational and other business decisions, developers can check data by using daily, weekly, or background reports, anytime and anywhere.


Question: What communication functions can I implement in my application by using Agora CaaS?
1. App-App Communication
2. App-Web Communication
3. Web-Web Communication
4. App-Cellphone/Local PSTN Breakout Communication.


Question: What are the differences between Agora.io and WebRTC?
WebRTC is based on P2P, and Agora.io is based on proprietary cloud services architecture that work with P2P as required.
WebRTC may/may-not work on Mobile but Agora.io will work on mobiles.
Voice quality is better with Agora as compare to WebRTC.
WebRTC does not store the video/audio, but Agora.io save the media and stored on their server.


Question: Does Agora.io use WebRTC?
In Web, Agora use WebRTC but with lot of customization which is not available in Normal Webrtc.
In App, Agora does not use WebRTC.


Question: What is the difference between Agora CaaS and a content-delivery platform (CDN)?
In CDN, latency can be from 1-10 Seconds.
In Agora, Latency can be upto 400ms.


Question: Is Agora.io a video cloud?
No, A video cloud provides video on demand and live service. but Agora.io provide real-time live streaming.



Question: Where Agoro.io can be used?
In Call center(BPO) with recording.
LIVE Streaming Audio with available of audio.
LIVE Streaming Video with available of video.
App-Web Audio/Video communication.
App-App Audio/Video communication.
Web-Web Audio/Video communication.
Send Audio message.
Send Video message.
Can be used Educational area as its cheap in cost.


Question: is encryption available in Agora?
Yes.
Agora.io is a safe platform
When the signal is sent, it is encrypted (call setup).


Question: Can we do custom encryption?
By Default Agora built-in AES-128 encryption. but we can use customized data encryption algorithm.


Question: What are the fees for Agora services?
The first 10,000 minutes of each month are free (Audio and Video combined).
Starting from the 10,001 minute of each month, $0.00099/minute (Audio call).
Starting from the 10,001 minute of each month, $0.00399/minute(Video call).


Question: Is Agora.io HIPAA compliant?
Yes.


Question: How does the Agora.io network handle DDoS attacks?
Yes, an anti-DDoS firewall is present in each cloud data center.


Question: Which platforms does Agora.io support?
Android > 4.0
IOS > 6.0


Question: Which codecs are used by Agora.io?
Agora.io uses its own proprietary audio codec, NOVA, which is simple, low-bit-rate, and highly adaptive.


Question: How many people does Agora.io audio/video support at the same time in a call?
Audio Call: up to 10,000 people at the same time
Video Call: up to 7 people at the same time



Question: Does Agora.io provide echo cancellation?
Yes.
Question: How much bandwidth does the Agora.io SDK require?
With Wifi (4KB to 13KB per second)
With Non-Wifi (4KB to 6KB per second)


Question: Is a call interrupted when switching networks, as from Wi-Fi to 3G/4G?
Yes, Short interruption after switching networks in a call, for example, from Wi-Fi to 3G or 4G, due to the clients's needs to re-establish connection.


Question: What is command for recording the media?
/usr/bin/recorder_local --appId APPID --appliteDir "/opt/Agora_Recording_SDK_for_Linux_FULL/bin" --channel aruntest1 



Question: What is command for (Recording Auddio/Video combine)?
/usr/bin/recorder_local --appId APPID --appliteDir "/opt/Agora_Recording_SDK_for_Linux_FULL/bin" --channel aruntest2 --mixedVideoAudio 1 --isMixingEnabled 1
/usr/bin/recorder_local --appId APPID --appliteDir "/opt/Agora_Recording_SDK_for_Linux_FULL/bin" --channel aruntest3 --mixedVideoAudio 1 --isMixingEnabled 1
/usr/bin/recorder_local --appId APPID --appliteDir "/opt/Agora_Recording_SDK_for_Linux_FULL/bin" --channel aruntest7 --mixedVideoAudio 1 --isMixingEnabled 1



Question: Command to set idle time?
/usr/bin/recorder_local --appId APPID --appliteDir "/opt/Agora_Recording_SDK_for_Linux_FULL/bin" --channel aruntest10 --mixedVideoAudio 1 --isMixingEnabled 1 --idle 4



Question: Command to set the root directory?
/usr/bin/recorder_local --appId APPID --appliteDir "/opt/Agora_Recording_SDK_for_Linux_FULL/bin" --channel aruntest10 --mixedVideoAudio 1 --isMixingEnabled 1 --idle 4 --recordFileRootDir /var/www/html/recording_files/



Question: What is offical Website of agora.io?
Main Website: https://www.agora.io/
SDK: https://www.agora.io/en/sdk/
Downloads: https://www.agora.io/en/download/
Price: https://www.agora.io/en/price/



Tuesday 17 April 2018

Rev: Online audio transcription, video captions and document translation services

Rev: Online audio transcription, video captions and document translation services

Question: What does Rev provide?
Rev provide the Online audio transcription, video captions and document translation services.


Question: What type of transcription they provide?
They provide transcription like immigration, business, legal, academic and personal needs.


Question: How much they charge?
Rev charges $1 per minute of audio. For example, a 30 minute clip costs $30.00. Timestamps and verbatim are options that cost $0.25 per minute each.


Question: How long will it take?
Audio files under 30 minutes long with good quality audio are typically delivered within 12 hours.


Question: Do they provide timestamps?
Yes, $0.25 per minute.


Question: What type of file format they accept?
We accept audio and video recordings in MP3, MP4, WMV, AIF, M4A, MOV, AVI, VOB, AMR, WMA, OGG, AAC, and WAV.


Question: What is endpoint for sandbox API?
https://api-sandbox.rev.com


Question: What is endpoint for Rev API?
https://www.rev.com


Question: What is documentation URL of API?
https://www.rev.com/api


Question: How to send order online for audio/video transcription?
Step 1
  1. Upload a source file to be used in an order via i.e. /api/v1/inputs
  2. Curl Example
curl -X POST
  https://api-sandbox.rev.com/api/v1/inputs
  -H 'authorization: AUTHORIZATION_STRING_HERE'
  -H 'cache-control: no-cache'
  -H 'content-type: application/json'
  -H 'postman-token: d6eee4bb-84ef-d54b-d15d-9ac9b3230fc2'
  -d '{
    "url": "https://useastpacificgeorama.blob.core.windows.net/useastpacifiddc/GM-qE2zq-1078-5525_720p.mp4"
}'


Response Headers
Location – URI identifying the newly uploaded media. This URI can be used to identify this media when submitting an order.


Step 2
  1. Now order online i.e. /api/v1/orders
  2. Curl Example
curl -X POST
  https://api-sandbox.rev.com/api/v1/orders
  -H 'authorization: AUTHORIZATION_STRING_HERE'
  -H 'cache-control: no-cache'
  -H 'content-type: application/json'
  -H 'postman-token: 10fa5ba8-3739-c3f2-ace9-b115f3bb6f96'
  -d '{
    "client_ref": "Georama-OvanTest",
    "transcription_options": {
        "inputs": [
            {
                "audio_length_seconds": 194,
                "uri": "urn:rev:inputmedia:U3VwbG9hZHMvMjAxOC0wNC0xMy8wMzQzOTY1MC0yMDVhLTQwMDYtYWZmMC01MjI0ZTdkNTQ2MTUvR00tcUUyenEtMTA3OC01NTI1XzcyMHAubXA0"
            }
        ],
        "verbatim": true,
        "timestamps": true
    },
    "notification": {
        "url": "http://example.com/callback/url",
        "level": "Detailed"
    }
}'

Response Headers
Location – URI identifying the newly created order. This URI can be used to request details (such as status) of the order. Only present if a 201 response code is returned.



Question: How rev will communicate to us once order is completed?
Once rev, received the request.
When they just start they will notify to us through callback function.
When they just complete they will notify to us through callback function.
All data will be sent in POST method, and have following parameters.
(
    [order_number] => TD0648810924
    [client_ref] => arunkumartest
    [status] => Complete
)



Question: How to GET order details online?
We can get the order details with API using orderId.
For Example.
curl -X GET
  https://api-sandbox.rev.com/api/v1/orders/TD0648810924
  -H 'accept: application/json'
  -H 'authorization: AUTHORIZATION_STRING_HERE'
  -H 'cache-control: no-cache'
  -H 'postman-token: aad7ead8-0b44-19b1-0f19-2b5baa4a2e6a'
Response Body
 
{
    "order_number": "TD0648810924",
    "client_ref": "OvanTest",
    "price": 4.86,
    "status": "Complete",
    "priority": "Normal",
    "non_standard_tat_guarantee": false,
    "transcription": {
        "verbatim": true,
        "timestamps": true,
        "total_length": 3,
        "total_length_seconds": 194
    },
    "comments": [
        {
            "by": "Georama I.",
            "timestamp": "2018-04-13T11:57:14.97Z"
        },
        {
            "timestamp": "2018-04-13T12:02:46.997Z",
            "text": "Order delivered"
        }
    ],
    "attachments": [
        {
            "kind": "media",
            "name": "GM-qE2zq-1078-5525_720p.mp4",
            "id": "5HYQOsWDAwAAAAAA",
            "audio_length_seconds": 194,
            "links": [
                {
                    "rel": "content",
                    "href": "https://api-sandbox.rev.com/api/v1/attachments/5HYQO2s2WDAwAAAAAA/content"
                }
            ]
        },
        {
            "kind": "transcript",
            "name": "sample_transcription.docx",
            "id": "5HYQOsqDAwAAAAAA",
            "links": [
                {
                    "rel": "content",
                    "href": "https://api-sandbox.rev.com/api/v1/attachments/5HYQO2sqDA2wAAAAAA/content",
                    "content-type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
                }
            ]
        }
    ]
}



Question: How to get transcriptions?
curl -X GET
  https://api-sandbox.rev.com/api/v1/attachments/5HYQO2s2WDAwAAAAAA/content
  -H 'accept: application/rev-transcription'
  -H 'authorization: AUTHORIZATION_STRING_HERE'
  -H 'cache-control: no-cache'
  -H 'postman-token: 4376e40d-9e6e-1e5a-e937-6337b9e1ade2'

Response
{"speakers":[{"id":1,"name":"Adam","icon":null,"color":null,"colorCoordinates":null,"note":null},{"id":2,"name":"Mike","icon":null,"color":null,"colorCoordinates":null,"note":null}],"monologues":[{"id":1,"speaker":1,"spans":[{"type":0,"value":"This is a sample first line"}],"startTime":null},{"id":2,"speaker":2,"spans":[{"type":0,"value":"This is a sample second line"}],"startTime":null}],"segments":[],"versionNumber":0,"offsetSeconds":0,"id":50,"name":"test.txt","metadata":{}}


Friday 15 September 2017

Web sockets online Tutorial - Page2

Web sockets online Tutorial - Page2

Question: Difference between socket and websocket?
WebSockets run from browsers and connecting to Server over a similar to HTTP. it require a permanent connection to its server.
Sockets are more powerful and generic and not restricted to http protocol OR browser.



Question: How to detect the message type in onmessage event?
  
socket.onmessage = function(event){
   if(typeOf event.data === String ) {
      console.log("Received data string");
   }
}



Question: How does Web Socket support Single TCP Connection?
In Web a new TCP connection is initiated for a each HTTP request and terminated after the response is received which means A new TCP connection need for each HTTP request. Whereas In WebSocket, the HTTP connection is upgraded and client and server communicate over that same TCP connection.


Question: How Web Socket support on Bi-directional?
In Web client(like browser) only can send the request to server then server send the response to the same client only.
Whereas In WebSocket, there is no pattern like request/response and Both (Client/Server) can send message to other party.


Question: How Web Socket support on Full Duplex?
In Web client(like browser) only can send the request to server then server send the response to the same client only. At a given time, either client is talking to server or server is talking to client. Whereas In WebSocket they can talk each other.


Question: What is the WebSocket API?
The WebSocket API is the asynchronous communication from client to server and it takes place over single TCP socket using the ws (unsecure) or wss (secure) protocol and can be used by any client or server application.


Question: How can we secure WebSocket API?
Normal Web Socket API start with ws but secure API start with wss.

Question: What is Ajax Long-Polling?
  1. A client requests a webpage using HTTP.
  2. The server does not immediately respond with the requested information but waits until there's new information available.
  3. When there's new information available, the server responds with the new information.
  4. The client receives the new information and immediately sends another request to the server, re-starting the process.



Question: What is Comet in HTML5?
Comet is a collection of techniques prior to HTML5 which use streaming and long-polling to achieve real time applications.


Question: What is Server Sent Events?
Server Sent Events (SSE) connections can only push data to the browser.
online stock quotes, or twitters updating timeline or feed are good examples of an application that could benefit from SSE.


Question: How to add http headers in Websockets client API?
We can not add custom header in Web sockets.


Question: How can we pass auth while calling Connecting WebSocket?
 var ws = new WebSocket("ws://username:password@example.com/path");



Question: Is PHP support for Web Sockets available?
Yes, for this you need install the library.
Apache Module: https://github.com/disconnect/apache-websocket
PHP WebSocket: http://code.google.com/p/phpwebsocket/
Ratchet: https://github.com/cboden/Ratchet
Wrench: https://github.com/varspool/Wrench


Tuesday 1 August 2017

Amazon Web Services Tutorial - Terminology

Amazon Web Services Tutorial - Basic understanding

Question: What is Amazon Web Services(AWS)?
AWS is Amazon's cloud web hosting platform that offers flexible, reliable, scalable, easy-to-use, and cost-effective solutions.


Question: What is cloud computing?
Cloud computing is an computing service in which large groups of remote servers are setup to allow centralized data storage, and online access to computer services or resources.


Question: What are the the benefits of Cloud Computing?
  1. AWS cost efficient
  2. Instantly setup of unlimited server
  3. Highly reliable
  4. Unlimited Storage
  5. Backup & Recovery
  6. Easy Access to Information



Question: What are the types of Cloud Computing?
  1. Public Cloud: Cloud computing services are managed by third party.
  2. Private Cloud: Cloud computing services are managed by own organization.
  3. Hybrid Cloud: Its combination of public cloud and private cloud.



Question: What are the Cloud Service Models of Cloud Computing?
  1. IaaS (Infrastructure as a Service): It provides users with provision of processing, storage, and network connectivity as per requirement.
  2. PaaS (Platform as a Service): The service provider provides various services like databases, queues, workflow engines, e-mails, etc. to their customers.
  3. SaaS (Software as a Service): Third-party providers provide end-user applications to their customers with some administrative capability at the application level.



Question: What is AWS EC2?
Full form of EC2 is Elastic Compute Cloud.
EC2 allow use virtual machines of different configurations as per their requirement.


Question: What is Load Balancing?
Load balancing means to balance the load on web server through adding resources on system. Load balancer manage the load on the server so that it work efficiently.


Question: What is Elastic Load Balancing?
Elastic Load Balancing is dynamically growing and shrinking the load-balancing capacity depending on server.


Question: What is Elastic Load Balancer?
It spread the traffic to web servers, which improves performance.
It is used to distributed the traffic to EC2 instances over multiple available zones, and dynamic addition and removal of Amazon EC2 hosts from the load-balancing rotation.


Question: What is Elastic Caches?
Amazon Elastic Cache is a web service that manages the memory cache in the cloud.


Question: What is Amazon RDS?
Relational Database Service (RDS) provides access of database like MySQL, Oracle, or Microsoft SQL Server database engine.


Question: What is AWS Management Console?
AWS Management Console is a web application for managing Amazon Web Services. It provide you detail about all servers and its resources, user billing/payment etc.


Question: What is Auto Scaling?
Auto Scaling is enabled by Amazon CloudWatch.
AWS CloudWatch can be used to measure CPU utilization, network traffic, etc.
When traffic increase then resource added automatically.


Question: What is Amazon Virtual Private Cloud?
Amazon VPC allows the users to use AWS resources in a virtual network.


Question: What services we can use with Amazon Virtual Private Cloud?
  1. Amazon EC2
  2. Amazon Route 53
  3. Amazon WorkSpaces
  4. Auto Scaling
  5. Elastic Load Balancing
  6. AWS Data Pipeline
  7. Elastic Beanstalk
  8. Amazon Elastic Cache
  9. Amazon EMR
  10. Amazon OpsWorks
  11. Amazon RDS
  12. Amazon Redshift



Question: What is Amazon Route 53?
It is a highly available and scalable DNS web service.
corporates to route the end users to Internet applications by translating human readable names like www.facebook.com, into the numeric IP addresses like 192.0.2.1.


Question: What is CloudFront?
CloudFront is a CDN retrieves data from Amazon S3 bucket and distributes it to multiple datacenter locations though edge locations.


Question: What is Amazon DynamoDB?
It is NoSQL database that allows to create database tables, store data in table and retrieve any amount of data.
It automatically manages the data traffic of tables over multiple servers and maintains performance.


Question: What is Amazon Redshift?
It is data warehouse service in the cloud. Its datasets range from 100s of gigabytes to a petabyte.


Question: What is Amazon Kinesis?
Amazon Kinesis is a managed, scalable, cloud-based service that allows real-time processing of streaming large amount of data per second.


Question: What is Amazon Elastic MapReduce?
Amazon Elastic MapReduce is a web service that provides a managed framework to run data processing frameworks such as Apache Hadoop, Apache Spark, and Presto in an easy, cost-effective, and secure manner.


Question: What is Amazon Pipeline?
AWS Data Pipeline is a web service, designed to make it easier for users to integrate data spread across multiple AWS services and analyze it from a single location.


Wednesday 15 March 2017

How to Send iOS push notification from PHP

How to Send iOS push notification from PHP?

PHP Code
//device token
$deviceToken = "a58c9e7406c4b591eda8f192027d00ef82cdba361821f693e7b8ac9cb3afbc61";

//Message will send to ios device
$message = 'this is custom message';

//certificate file
$apnsCert = 'pushcert.pem';
//certificate password
$passphrase = 1234;

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $apnsCert);
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);


// Create the payload body
$body['aps'] = array(
    'badge' => +1,
    'alert' => $message,
    'sound' => 'default'
);

$payload = json_encode($body);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;

// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));

if (!$result)
    echo 'Message not delivered' . PHP_EOL;
else
    echo 'Message successfully delivered amar' . $message . PHP_EOL;

// Close the connection to the server
fclose($fp);



Question: What is full form of APNS?
Apple Push Notification Service


Question: What is device token in ios?
Device token is an identifier for the Apple Push Notification System for iOS devices.


Question: What is apnsHost for Development and LIVE?
Development Server
ssl://gateway.sandbox.push.apple.com:2195

Production Server
ssl://gateway.push.apple.com:2195



Question: From where we can test the APN Host?
http://pushtry.com/


Question: What port need to enable for APNs notification?
2195
2196
 



Monday 13 March 2017

IMAP Gmail read messages details from inbox

IMAP Gmail read messages details

Check that IMAP is turned on
If Not, Please enable.


Library Code

/** functions used for getting message **/
function flattenParts($messageParts, $flattenedParts = array(), $prefix = '', $index = 1, $fullPrefix = true) {

    foreach($messageParts as $part) {
        $flattenedParts[$prefix.$index] = $part;
        if(isset($part->parts)) {
            if($part->type == 2) {
                $flattenedParts = flattenParts($part->parts, $flattenedParts, $prefix.$index.'.', 0, false);
            }
            elseif($fullPrefix) {
                $flattenedParts = flattenParts($part->parts, $flattenedParts, $prefix.$index.'.');
            }
            else {
                $flattenedParts = flattenParts($part->parts, $flattenedParts, $prefix);
            }
            unset($flattenedParts[$prefix.$index]->parts);
        }
        $index++;
    }

    return $flattenedParts;
           
}


function getPart($con, $messageNumber, $partNumber, $encoding) {
   
    $data = imap_fetchbody($con, $messageNumber, $partNumber);
    switch($encoding) {
        case 0:
            return $data;
            break; // 7BIT
        case 1:
            return $data;
            break;// 8BIT
        case 2:
            return $data; // BINARY
            break;
        case 3:
            return base64_decode($data);  // BASE64
            break;
        case 4:
            return quoted_printable_decode($data); // QUOTED_PRINTABLE
            break;
        case 5:
            return $data; // OTHER
            break;
    }   
   
}


function getFilenameFromPart($part) {

    $filename = '';
   
    if($part->ifdparameters) {
        foreach($part->dparameters as $object) {
            if(strtolower($object->attribute) == 'filename') {
                $filename = $object->value;
            }
        }
    }

    if(!$filename && $part->ifparameters) {
        foreach($part->parameters as $object) {
            if(strtolower($object->attribute) == 'name') {
                $filename = $object->value;
            }
        }
    }
   
    return $filename;
   
}

/** functions used for getting message **/



How to read specific message
$username = 'mygmail@gmail.com'; //Gmail address
$password = 'gma12#@c'; //Gmail password
error_reporting(0);

 $bodyId=35; //This is message Id

 //Read Message from indebox
    $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
   
   //Read Message from Trash
    // $hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/Trash';
 
   //Read Message from Sent
 //$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/Sent Mail';




$con = imap_open($hostname, $username, $password);
$messageNumber = $bodyId;
$structure = imap_fetchstructure($con, $messageNumber);
//pr($structure);die;

$message='';
if(!empty($structure->parts)){
 
 $flattenedParts = flattenParts($structure->parts); 
 foreach($flattenedParts as $partNumber => $part) {  
  switch($part->type) {
     
   case 0:
    // the HTML or plain text part of the email
    $message = getPart($con, $messageNumber, $partNumber, $part->encoding);
    // now do something with the message, e.g. render it
      
   break;
    
   case 1:
    // multi-part headers, can ignore
    
   break;
   case 2:
    // attached message headers, can ignore
   break;
    
   case 3: // application
   case 4: // audio
   case 5: // image
   case 6: // video
   case 7: // other
   //pr($part);
   //echo "
$$$$$";
    $filename = getFilenameFromPart($part);
    if($filename) {
     // it's an attachment
     $attachment = getPart($con, $messageNumber, $partNumber, $part->encoding);
        if (empty($filename))
      $filename = $filename;
       
     if (empty($filename))
      $filename = time() . ".dat";
     $folder = "attachment";
     if (!is_dir($folder)) {
      mkdir($folder);
     }
     $fp = fopen("./" . $folder . "/" . $messageNumber . "-" . $filename, "w+");
     fwrite($fp, $filename);
     fclose($fp);
     // now do something with the attachment, e.g. save it somewhere
     $message.='

' . $messageNumber . '-' . $filename . '
'; } break; } } }else{ $message = getPart($con, $messageNumber, 1, $structure->encoding); } if($message){ $message=$message; } echo $message; imap_close($con, CL_EXPUNGE);



Thursday 11 August 2016

How to Convert Youtube Data API V3 video duration format to seconds in PHP?

How to Convert Youtube Data API V3 video duration format to seconds in PHP?

We get the youTube Video duration in below way from Youtube V3 API.
 "contentDetails": {
    "duration": "PT15S",
    "dimension": "2d",
    "definition": "sd",
    "caption": "false",
    "licensedContent": true,
    "projection": "rectangular"
   },

Now, We need to convert the duration to number of seconds.
Following are Simple PHP Function which convert the API V3 video duration format to number of seconds.
 function duration($ytDuration) {
    $di = new DateInterval($ytDuration);
    
    $totalSec = 0;
    if ($di->h > 0) {
      $totalSec+=$di->h*3600;
    }
    if ($di->i > 0) {
      $totalSec+=$di->i*60;
    }
    $totalSec+=$di->s;
    
    return $totalSec;
  }
$youtubeTime = 'PT15S';
 echo duration($youtubeTime);//15
 
 
$youtubeTime = 'PT2M55S'; 
echo duration($youtubeTime);//175

$youtubeTime = 'PT1H35M23S'; 
echo duration($youtubeTime);//5723

Wednesday 27 July 2016

How to detect and change Browser user agent?

How to detect and Browser user agent?

Question: What is Browser user agent?
It is software agent which acting on behalf of a user.
Actually it s user agent is a Single line of string which helps to detect the request. When an request is sent to web server then user agent of browser is also sent in header which helps the web server to identifying the browser and operating system.


Question: What is use of Browser user agent?
It helps the web server to identifying the browser and operating system.
Means with the help of user agent, web server can get the know which browser of OS is request the data.
Web site uses this customize content for the capabilities of a particular device.


Question: Who is using of Browser user agent?
Web Server (Websites) are using the user agent. With the help of user agent they get to know mobile OR Desktop.
then web server sent back the data as per requested device.


Question: How user agent is sent to Server?
When an browser send request to web server. then request header is sent to web server along with request data.


See Example of Request Header:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.5
Cache-Control:max-age=0
Connection:keep-alive
Cookie:user_segment=Prospect; _ga=GA1.2.1900507711.1469603080
Host:example.georama.loc
Referer:http://example.georama.loc/
User-Agent:Mozilla/5.0 (Windows NT 6.1; rv:47.0) Gecko/20100101 Firefox/47.0

User Agrent is
User-Agent:Mozilla/5.0 (Windows NT 6.1; rv:47.0) Gecko/20100101 Firefox/47.0
Above is user agent of mozilla having version 47.0


Question: What is my current user agent ?
http://www.useragentstring.com/


Question: How to detect Browser user agent?
with use of user agent string, you can detect the browser and OS. Open: http://www.useragentstring.com/ Add the user agent string and click on Analyse.


Question: Can we change Browser user agent? If Yes, How?
Yes, We can change the user agent.
With help of User-Agent Spoofing, We can change the user agent.


Question: What is User agent spoofing?
Spoofing means behave differently than in actuality.


Question: Who is User agent spoofing?
Spam bots, Web scrapers, hackers uses the spoofing to hide their identity.


Question: How to change the useragent in Chrome, Safari & Firefox?
http://osxdaily.com/2013/01/16/change-user-agent-chrome-safari-firefox/


Monday 25 July 2016

How to add Subtitles, Caption, Chapters and Descriptions in jwplayer video

How to add Subtitles, Caption, Chapters and Descriptions  in jwplayer video

Question: What is Subtitles, Captions, Chapters and Descriptions?
Subtitles: Translation of the dialogue like movie subtitles.
Captions: Similar to Subtitles but may include sound effects.
Chapters: Display the marker in video player bar to help the user for navigation.
Descriptions Or thumbnails: Similar to Subtitles but may include sound effects.


Question: How to add Subtitles, Captions, Chapters and Descriptions in JwPlayer?
 
<script src="//content.jwplatform.com/libraries/bFyELn2w.js"></script>
<div id="videoPlayerId2">
</div>
<script type="text/javascript">
    var playerObj = jwplayer("videoPlayerId2"); 
    playerObj.setup({
        image: "//content.jwplatform.com/thumbs/q1fx20VZ-640.jpg",
        file: "//content.jwplatform.com/videos/q1fx20VZ-640.mp4",
        tracks: [            
            
            /* subtitle **/
            {file: '//content.jwplatform.com/tracks/XtwSLSdq.txt',kind: 'subtitles'},
            
            /* captions **/
            {file: '//content.jwplatform.com/tracks/XtwSLSdq.txt',kind: 'captions'},
            
            /* Chapters **/
            {file: '//content.jwplatform.com/tracks/XtwSLSdq.txt',kind: 'chapters'},
            
            /* Descriptions **/
            { file: "//content.jwplatform.com/strips/3p683El7-120.vtt", kind: "thumbnails" },
            

        ],
        width: 640,
        height: 400
    }); 
</script> 


Demo



Question: Give the chapter sample file?
1
00:00:00,000 --> 00:01:42,000
Opening credits

2
00:01:42,000 --> 00:04:44,000
A dangerous quest

3
00:04:44,000 --> 00:05:50,000
The attack

4
00:05:50,000 --> 00:08:24,000
In pursuit

5
00:08:24,000 --> 00:10:13,000
Showdown in the cage

6
00:10:13,000 --> 00:12:24,000
Eye to eye

7
00:12:24,000 --> 00:14:48,000
Ending Credits



Question: Give the subtitle/captions sample file?
1
00:00:00,000 --> 00:01:42,000
Opening credits

2
00:01:42,000 --> 00:04:44,000
A dangerous quest

3
00:04:44,000 --> 00:05:50,000
The attack

4
00:05:50,000 --> 00:08:24,000
In pursuit

5
00:08:24,000 --> 00:10:13,000
Showdown in the cage

6
00:10:13,000 --> 00:12:24,000
Eye to eye

7
00:12:24,000 --> 00:14:48,000
Ending Credits



Question: Give the Descriptions sample file?
00:00.000 --> 00:51.833
3p683El7-120.jpg#xywh=0,0,120,67

00:51.833 --> 01:43.667
3p683El7-120.jpg#xywh=120,0,120,67

01:43.667 --> 02:35.500
3p683El7-120.jpg#xywh=240,0,120,67

02:35.500 --> 03:27.334
3p683El7-120.jpg#xywh=360,0,120,67

03:27.334 --> 04:19.167
3p683El7-120.jpg#xywh=0,67,120,67

04:19.167 --> 05:11.001
3p683El7-120.jpg#xywh=120,67,120,67

05:11.001 --> 06:02.834
3p683El7-120.jpg#xywh=240,67,120,67

06:02.834 --> 06:54.668
3p683El7-120.jpg#xywh=360,67,120,67
Here 3p683El7-120.jpg is image path, placed parallel with vtt file.

Friday 22 July 2016

How to add chapter in jwplayer video?

How to add chapter in jwplayer video?

Question: How to add marker in jwplayer video?
 
<script src="//content.jwplatform.com/libraries/bFyELn2w.js"></script>
<div id="videoPlayerId">
</div>
<script type="text/javascript">
    var playerObj = jwplayer("videoPlayerId");


    playerObj.setup({
        image: "//content.jwplatform.com/thumbs/q1fx20VZ-640.jpg",
        file: "//content.jwplatform.com/videos/q1fx20VZ-640.mp4",
        tracks: [{
                file: '//content.jwplatform.com/tracks/XtwSLSdq.txt',
                kind: 'chapters'
            }],
        width: 640,
        height: 400
    }); 
</script> 


Demo



Question: Give the chapter sample file?
1
00:00:00,000 --> 00:01:42,000
Opening credits

2
00:01:42,000 --> 00:04:44,000
A dangerous quest

3
00:04:44,000 --> 00:05:50,000
The attack

4
00:05:50,000 --> 00:08:24,000
In pursuit

5
00:08:24,000 --> 00:10:13,000
Showdown in the cage

6
00:10:13,000 --> 00:12:24,000
Eye to eye

7
00:12:24,000 --> 00:14:48,000
Ending Credits



Question: What are 3 option in chapter?
identifier (optional )
Its for personal use.

Cue timings (required)
What are timing (start-end) to show the chapter/market.

Chapter title (required)
What title when want to show when click on that marker or chatper.


Thursday 21 July 2016

How to remove the YouTube Logo from the Video Player?

How to remove the YouTube Logo from the Video Player?

Question: How to remove the YouTube Logo from the Video Player?
<iframe height="300" src="//www.youtube.com/embed/myaqHeNEO04?modestbranding=1" width="400"></iframe>

Demo




Question: How to autoplay the youtube video when embed in website?
<iframe height="300" src="//www.youtube.com/embed/myaqHeNEO04?modestbranding=1&amp;autoplay=1" width="400"></iframe>

Demo




Question: How to Stop autoplay the youtube video when embed in website?
<iframe height="300" src="//www.youtube.com/embed/myaqHeNEO04?modestbranding=1&amp;autoplay=0" width="400"></iframe>

Demo




Question: How to remove related videos from the end of an embedded youtube video?
<iframe height="300" src="//www.youtube.com/embed/myaqHeNEO04?modestbranding=1&amp;autoplay=0&amp;rel=0" width="400"></iframe>

Demo




Wednesday 20 July 2016

How to embed muted youtube video with autoplay

How to embed muted youtube video with autoplay

Question:How to Embed muted youtube video with autoplay?
<iframe allowfullscreen="" frameborder="0" height="300px" id="ytplayer" src="https://www.youtube-nocookie.com/embed/2gcfHpGpsOw?rel=0&amp;enablejsapi=1&amp;autoplay=1&amp;controls=1&amp;showinfo=0&amp;loop=1&amp;iv_load_policy=3" type="text/html" width="400px"></iframe>
<script>
var player;

function onYouTubeIframeAPIReady() {
    player = new YT.Player('ytplayer', {
        events: {
            'onReady': onPlayerReady
        }
    });
}

function onPlayerReady(event) {
    player.mute();
    player.playVideo();
}    
    </script>


Question:How to Embed muted youtube video without autoplay?
<iframe allowfullscreen="" frameborder="0" height="300px" id="ytplayer" src="https://www.youtube-nocookie.com/embed/2gcfHpGpsOw?rel=0&amp;enablejsapi=1&amp;autoplay=0&amp;controls=1&amp;showinfo=0&amp;loop=1&amp;iv_load_policy=3" type="text/html" width="400px"></iframe>
<script>
var player;

function onYouTubeIframeAPIReady() {
    player = new YT.Player('ytplayer', {
        events: {
            'onReady': onPlayerReady
        }
    });
}

function onPlayerReady(event) {
    player.mute();
    player.playVideo();
}    
    </script>

Demo