I created a Facebook App using PHP on my website. To use this application on my website the user must login using Facebook authentication.
This app basically lets the user post a default comment on his wall. It works fine using my facebook profile account, but when I asked my friend to use my site he gets the following error - 'Uncaught OAuthException: (#200) The user hasn't authorized the application to perform this action thrown in'
The only solution to my problem i found till now is by entering the following URL - <pre>https://www.facebook.com/login.php?api_key=API_KEY&cancel_url=http://www.magimagi.com&next=http://magimagi.com/login/uploadtopage2.php&fbconnect=1&return_session=1&session_version=3&v=1.0&display=page&req_perms=user_about_me,user_birthday,publish_stream,offline_access</pre>
I do not want to create a link on my app for the user to click it - instead I want it integrated into the PHP code already on my website.
Here is a sample PHP code I have
<pre>
/ Get User ID
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl( array(
'scope' => 'publish_stream'
));
}
</pre>
This is the HTML
<pre>
<form id="selectFriend" name="selectFriend" method="post">
<label for="Friend">Friend:</label>
<select id="friend" name="friend">
<?php
foreach($user_friends['data'] as $f){
echo '<option value="'.$f['id'].'">'.$f['name'] .'</option>';
}
?>
</select>
<label for="URL">URL:</label>
<input id="link" name="link">
<input id="message" name="message">
<input type="submit" name="submit" id="submit" value="Send!">
</form>