PHP in .aspx pages
4 posts
• Page 1 of 1
PHP in .aspx pages
Hi
I Have a C# ASP.NET Web Forms Project i want to use php to connect to Facebook php SDK.
I use php in .aspx (html side).
and C# to do all the other code in the .aspx.cs
The aspx pages does't execute the code at all.
If i put the code in a php page inside my asp project it kind of works but i get an error.
I use facebook example code that comes with the sdk.
i can see on the php page it loads in the facebook.php page.
but i get this error:
Error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in path...\src\base_facebook.php:19:3 Stack trace: #10 : Process #9 : ProcessRequest #8 : ProcessRequestNoDemand #7 : ProcessRequestInternal #6 : System.Web.IHttpAsyncHandler.BeginProcessRequest #5 : ResumeSteps #4 : ExecuteStep #3 : System.Web.HttpApplication.IExecutionStep.Execute #2 : #1 path...\example.php(18,1): #0 path...\src\facebook.php(18,1): #11 {main}.
The aspx page just print out the code like it was plain text.
Please Help
Thank you
I Have a C# ASP.NET Web Forms Project i want to use php to connect to Facebook php SDK.
I use php in .aspx (html side).
and C# to do all the other code in the .aspx.cs
The aspx pages does't execute the code at all.
If i put the code in a php page inside my asp project it kind of works but i get an error.
I use facebook example code that comes with the sdk.
i can see on the php page it loads in the facebook.php page.
but i get this error:
Error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in path...\src\base_facebook.php:19:3 Stack trace: #10 : Process #9 : ProcessRequest #8 : ProcessRequestNoDemand #7 : ProcessRequestInternal #6 : System.Web.IHttpAsyncHandler.BeginProcessRequest #5 : ResumeSteps #4 : ExecuteStep #3 : System.Web.HttpApplication.IExecutionStep.Execute #2 : #1 path...\example.php(18,1): #0 path...\src\facebook.php(18,1): #11 {main}.
The aspx page just print out the code like it was plain text.
- Code: Select all
<?php
/**
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
require 'src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => '344617158898614',
'secret' => '6dc8ac871858b34798bc2488200e503d',
));
// Get User ID
$user = $facebook->getUser();
// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
}
// This call will always work since we are fetching public data.
$naitik = $facebook->api('/naitik');
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>php-sdk</title>
<style>
body {
font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
}
h1 a {
text-decoration: none;
color: #3b5998;
}
h1 a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>php-sdk</h1>
<?php if ($user): ?>
<a href="<?php echo $logoutUrl; ?>">Logout</a>
<?php else: ?>
<div>
Login using OAuth 2.0 handled by the PHP SDK:
<a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
</div>
<?php endif ?>
<h3>PHP Session</h3>
<pre><?php print_r($_SESSION); ?></pre>
<?php if ($user): ?>
<h3>You</h3>
<img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
<h3>Your User Object (/me)</h3>
<pre><?php print_r($user_profile); ?></pre>
<?php else: ?>
<strong><em>You are not Connected.</em></strong>
<?php endif ?>
<h3>Public profile of Naitik</h3>
<img src="https://graph.facebook.com/naitik/picture">
<?php echo $naitik['name']; ?>
</body>
</html>
Please Help
Thank you
- Madde
- Posts: 7
- Joined: December 13th, 2012, 2:50 pm
Re: PHP in .aspx pages
Thats not actually a PHP Tools question, but why don't you use the .net API from Facebook?
Mixing PHP/ASP.NET ist a bad idea IMHO if even possible, because they have totaly different aproaches, but maybee the guys here can help as they have the know-how from Phalanger...
Mixing PHP/ASP.NET ist a bad idea IMHO if even possible, because they have totaly different aproaches, but maybee the guys here can help as they have the know-how from Phalanger...
- CFI
- Posts: 66
- Joined: December 13th, 2012, 1:29 pm
Re: PHP in .aspx pages
There is no .net for facebook.
I tried the javascript but to many users had problems.
The php and the C# doesn't have to talk to each other i just use the php to authenticate the facebook user and build a like gate. (the user have to like a page before they use my app. i write different html if the user doesn't like a page.)
I tried the javascript but to many users had problems.
The php and the C# doesn't have to talk to each other i just use the php to authenticate the facebook user and build a like gate. (the user have to like a page before they use my app. i write different html if the user doesn't like a page.)
- Madde
- Posts: 7
- Joined: December 13th, 2012, 2:50 pm
Re: PHP in .aspx pages
Yes, there is :
http://nuget.org/packages/Facebook/6.1.4
http://nuget.org/packages/Facebook/6.1.4
- CFI
- Posts: 66
- Joined: December 13th, 2012, 1:29 pm
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 53 guests