Saturday 12 June 2021

Test Web Apps on all browsers online

Test Web Apps on different browsers online


Browserstack is the best solution to test website UI/UX on different browsers simulators at single place online.



browserstack

Click here for more info:




I used this https://www.browserstack.com/ for my apps to test UI/UX and performance of my apps. We can get following browsers at one place:
  1. Google Chrome - All Versions
  2. IE - All Versions 
  3. Safari - All Versions
  4. Android - All Versions
  5. IOS - All devices, All Versions
  6. Opera browsers


Tuesday 8 June 2021

Microsoft Graph API PHP

Microsoft Graph API PHP Tutorials

I am sharing some basic sample PHP code for Microsoft Graph API. May this will  helpful for someone.

For full reference, go to GIT URL:

PHP Framework Laravel Sample Code GIT URL:





















To start, you should have Outlook/Hotmail or any Microsoft Account.

First required to register App on Azure Active Directory. You can create App on Azure even if you have School or Organization account.

Graph API will generate Microsoft Authentication URL, where user will redirect and after successful login he will redirect back callback URL. Callback URL need to define in Azure App.

User can get Calendar events based on dates provided. User can create events on their Calendar.

Sharing Create Calendar Event using Microsoft Graph API.

<?php
// POST /me/events
$events_response = $graph->createRequest('POST', '/me/events')
    ->attachBody($newEvent)
    ->setReturnType(Model\Event::class)
    ->execute();


Get Calendar Events using Microsoft Graph API

<?php

$userEventsArr = $graph->createRequest('GET', $getEventsUrl)
// Add the user's timezone to the Prefer header
    ->addHeaders(array(
        'Prefer' => 'outlook.timezone="' . $userTimezone . '"',
    ))
    ->setReturnType(Model\Event::class)
    ->execute();

Sunday 6 June 2021

Calculate Number of Days PHP

Calculate Number of Working Days Between Two Days in PHP

I am sharing my PHP code to get difference between two dates.

$workingDays = 0;

$startTimestamp = strtotime('2021-06-03');
$endTimestamp = strtotime('2022-07-09');
for ($i = $startTimestamp; $i <= $endTimestamp; $i = $i + (60 * 60 * 24)) {
    if (date("N", $i) <= 5) $workingDays = $workingDays + 1;
}

echo "no. of days: " . $workingDays;

Save code in nofdays.php.

Run program in terminal. Output will be:

$ php nofdays.php

no. of days: 287




Create .ICS file using PHP code

Recently worked on creating a .ics file in PHP after a very long time, code so thought to share with everybody. Please find below the comple...