Author Archives: Admin

why showing this error in{“error”:”invalid_request”,”error_description”:”Missing grant_type parameter value”} in accesstoken creation in rest api

$service_url =’http://mydoubts.in/apspackage/’
$curl = curl_init();
curl_setopt($curl,CURLOPT_HTTPHEADER,array (“Content-Type:application/x-www-form-urlencoded”));

curl_setopt($curl, CURLOPT_POST, 1); // Do a regular HTTP POST

curl_setopt($curl, CURLOPT_POSTFIELDS, ‘client_id=’ . urlencode($client_id) . ‘&’ .
‘client_secret=’ . urlencode($client_secret) . ‘&’ .
‘grant_type=client_credentials’ . ‘&’ .
‘scope=openid’);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, FALSE);
curl_setopt($curl, CURLOPT_USERAGENT, “Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)”);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_URL, $service_url);
$response = curl_exec($curl);

print_r($response);

this will work enjoy 🙂

PHP Sessions

Session variable stores the information about a user that variable will be availbale to all pages and we can handle the login track using the session concept

Session is time duration when the user start to browse a webpage and it will be live until the page close.

in php we will use the ‘session_start();’ function at the begining of a php page

for example

$_SESSION[‘mydoubts’]=’somevalue’;

in each page we can check the session is set or not using the below script

if(isset($_SESSION[‘mydoubts’]))

{

// shows the page you want to display
}

else

{

// redirect home page.

}

For destorying the session

session_destroy()

Forms in php

In PHP webapplication development to collect form data to another page we will use

the following methods

$_GET– this is used in the case when the form action is GET
$_POST– this is used in the case when the form action is POST

Sample form as below

index.php
———


Name:
Age:


innerpage.php
————-

if we change the method as GET in index.php like below

Then inner.php will change as to

Note: if you print the post and get varibles print using print_r in inner.php then you can see that it will return as an array.

addcslashes() function in PHP

It Resturns a string with backslashes infront of the characters.

this function is case-sensitive


Syntax
——

addcslashes(string,characters)

Both parameters are required fields.
string-this is the String to be escaped
characters-this is the characters/range of character to be escaped

Example
——-

$mystring=”Welcome to mydoubts”;
echo addcslashes($mystring,’m’);

Above statement will print the output as below

Welco\me to \mydoubts

note: you can escape multiple characters using a..z in the above function you can use instead of m put a..z.