I have created a JSON file which I will use as a datasource for global configurations of the app.
Excerpt from json file
//Have not put the complete json file. No error in the file
{
"loginType":[
{
"name":"Facebook",
"url":"#",
"method":"",
"label":"Continue with Facebook",
"type":"social",
"class":"",
"icon":"",
"callBack_url" : "fbLoginUrl",
"providerButton":"<div class='fb-login-button' data-max-rows='1'
data-size='large' data-button-type='continue_with' data-use-
continue-as='true'></div>"
},
{
"name":"Twitter",
"url":"#",
"method":"logInWithTwitter()",
"label":"Continue with Twitter",
"type":"social",
"class":"",
"icon":"",
"callBack_url" : "twitterLoginUrl",
"providerButton" :""
}
]
}
The callBack_url key in the json file has a variable with a similar name which has a url as its value e.g $twitterLoginUrl = "https://some.site.com/twitter_login?param1"
$jsonData_signIn =json_decode
(file_get_contents(/path/to/oauth2_provider.json));
$oauth2Provider = jsonData_signIn->loginType;
foreach($oauth2Provider as $type){
if($type->type == 'local' ){
echo "<a href=\"{$type->callBack_url}\">{$type->label}</a>";
}
}
For the above, as output for the link I get eg <a href="$fbLoginURL">Continue with facebook</a>
echo "<a href=\"{${$type->callBack_url}}\">{$type->label}</a>";
The reason I am not storing the complete URI is I will generate some parameters dynamically.