I have a webpage hosted in my local server being displayed inside a Page Viewer Web Part in SharePoint 2007.
I would like to include a user check inside the pages in my server, so when an user tried to access some page through the SharePoint web part, the page would first check who is the user logged in SharePoint trying to access the page, and then check if the specific user is allowed to see that page.
I have tried the most common solutions found online using js and/or php: SPAPI, SPContext and Jquery SPServices, but wasn't able to make any of them work with the php pages in my local server.
Is there a practical way to get the user who is accessing the page? I am new to web development, so I would appreciate any help.
in your case the problem is how to pass user identity from SharePoint to your PHP page as SharePoint user (as well as any other SP information) is not accessible directly in page displayed within Page Viewer webpart. Page Viewer webpart uses IFRAME to display specified page.
I suggest you to use ContentEditor webpart to include your own IFRAME and some javascript to the SharePoint page. Within the javascript you can use SPServices to get user info and pass it to SRC attribute of IFRAME as the part of PHP page URL .
Drawback of this is that advanced user can construct the the URL by itself and pass username of another user.
Related
I am trying to make a webpage that only new users can see if a returning viewer returns he will be redirected to another webpage I found this on stackoverflow but I am unable to figure it out.
I have made a HTML and CSS page which showcases the features of my web app. I want this page to load only for new visitors. If a returning visitor visits my domain, it should redirect him/her to the web platform. Essentially, the new user should see "Landing Page" while a returning user should be redirected to "Web Platform"
The answer was
How do I make a web page show up only once?
I am unable to use it because I don't know what to do and how to create localstorage
You should use PHP code to make a webpage only available once with SESSION and log.
I have a problem with my fanpage. A gallery script is running a my webspace and i put it in the app also in th iframe of the Fanpage. The gallery script has get an Share button to post the photos on facebook. This part of it is running fine but when i clicked the link that was posted in Facebook i had been reffered to my page on my webspace and not to the iframe with the webpage and the photo. Is it possible to edit the link to go to this page in facebook iframe?
This is not a problem in general. You can try to redirect your website into the Facebook tab application my checking the HTTP_REFERRER and the url. You might have a look at this example
There is an URL you can try to call and see if you get redirected to the right application. Additionally, you can add app_data-parameters to the URL to identify the real target into your app.
All that can be done by the following code:
// set the target facebook page name and id to perform a forceRedirectToTab()
$tmpFbHelper
->setPageName($iniHandler->getIniSetting('facebook.'.fbHelper::getAppNamespace().'.page.name'))
->setPageId($iniHandler->getIniSetting('facebook.'.fbHelper::getAppNamespace().'.page.id'))
->setSecret($iniHandler->getIniSetting('facebook.'.fbHelper::getAppNamespace().'.secret'));
// perform a redirect to the facebook tab application if someone opens the url out of facebook
// the facebook-linter is not affected by this :)
$tmpFbHelper->forceRedirectToTab();
// perform a deeplink if for example a special url is called or you identify some app-data
$tmpFbHelper->performDeeplink();
You will have to look at your published links into the stream so that the PHP-code finds out that you will redirect and deeplink!
I hope this ideas might help you :)
I am developing a Flash game for Facebook that uses PHP to access MySQL to store users game info. I am a bit stuck right now though. Here is my scenario.
User logs into Facebook and starts app which calls index.php and houses my Flash game. (works fine).
I use $facebook->getUser(); to authenticate and begin gathering user information (also works fine).
Flash will then access a getdata.php file on my server that will access MySql and echo certain info (ie. fname=John&lname=Doe&age=25).
Step 3 is the problem and I'll do my best to explain it...
My getdata.php also does a $facebook->getUser(); authentication, but the user is NOT authenticated on that script, whereas within the IFRAME app, the user is still authenticated. I'm assuming it has something to do with the fact that the main page is within Facebook's IFRAME and is possibly seen as a different session than when Flash tries to connect with my getdata.php file on my server. Is this the case? And can anyone help point me in the right direction as to how I might use Flash within an IFrame app to access a script on my server to retreive variables?
EDIT: I should mention that I'm using ActionScript 3 for Flash, but I'm fairly certain the problem doesn't lie there because it will retrieve the variables, but since the user is not authenticated on the server, then it will return a success=0.
Also wanted to point out that if I access my flash game through my actual server, and not Facebook, then all works well. Another reason why I think it's a session-type problem.
This is a session problem. You should try to pass the facebook signed_request, or any data you can use to build a valid user session, into your flash file and then pass them back to getdata.php where it can be used to access the users data.
I'm trying to do something similar to the login/registration flow described on this page but via php only.
http://developers.facebook.com/docs/plugins/registration/
What I want to do is display a register link if a user is logged in to facebook but not registered with my site, and a login link if they're not logged in to facebook, however I want to do this all on my side in php, and not using the fb:login-button widget. Is this possible?
I have the login url working, i just want to change the name of the button based on the users status.
You can't do it without loading the javascript lib. If you load nothing from Facebook on the client, then there is no way to do cross domain communication (security). Which means there is no way to tell who the user is, much less if they are logged into Facebook. By loading the javascript API on the client, the javascript code can check for a Facebook cookie and determine who they are and whether they are logged into Facebook or not.
Check through javascript and do a page reload if need be. Better yet, just use css to show/hide what you want.
http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/
Yes, it is possible. Here's a tutorial:
Tutorial,
Example tutorial
I am currently using this recently written tutorial on authorizing an application with facebook using auth 2.0 and it works. the application authorizes correctly and uses the GraphAPI.
http://kartiklad.com/oauth-2-0-and-graph-api-for-facebook-canvas-applications/
But the problem is using the IFrame with a multi page website and this method of authentication, each time a different page is called, it has to go back to authentication page which will redirect the user page to the application, which makes it impossible to pass variables using $_GET.
So how would anyone else here suggest passing variables from one page to the next in an iframe?
This is probably not needed by the application I am working on is at : http://apps.facebook.com/prtrackevents/
The problem is that your urls are only navigating within the frame. The authentication of facebook is including your session variables inside a ?session=... query tag on your frame so that when you navigate to a url in your iframe you loose the ?session querystring value so then your app has to re authenticate. The fix is that your links must include target="_top" so that they cause the entire page to change positions. For example, your details link should be like this:
Details