|
|
 Nick - 2014-12-10 19:17:54
Hi I am trying to apply the login_with_twitter.php oauth script to a drupal template and it all works great ! I am just having an issue with the redirect after I am sent to twitter to authorize the app. I go ahead and do that then I am redirected to https://api.twitter.com/oauth/authenticate and once it hits this url it keeps looping and never redirects back to the page ?
I can provide any code or info that would help solve this issue thanks !
Nick
 Manuel Lemos - 2014-12-10 22:16:24 - In reply to message 1 from Nick
By default the class uses sessions to store the OAuth access token state. If you have sessions disabled, it may not work.
 Nick - 2014-12-11 18:53:13 - In reply to message 2 from Manuel Lemos
Hi Manuel,
thanks for the reply !
I am going to look into this.
I think drupal has its own way of handling sessions so that may be tripping it up.
Because I know that I was able to get it to work in pages that were not in a node.tpl.php file
Is it possible for me to use ajax to communicate with your script ? so I dont run it directly from my template, therefore avoiding the possible session issue.
thanks again
Nick
 Manuel Lemos - 2014-12-12 05:52:50 - In reply to message 3 from Nick
No, your users need to be redirected to Twitter site so they can give permission to access Twitter API on their behalf.
Another thing, is that your system must not output anything to the pages before calling this class, as it needs to redirect the user setting headers.
 Nick - 2014-12-12 20:20:03 - In reply to message 4 from Manuel Lemos
Hi Manuel,
I was able to get it working by adding this to my node.tpl.php
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
I am now able to access the class directly in the node.tpl.php
My one other question is ->
I was able to get the post to twitter working just fine no problem there.
The issue came when I was trying to post on behalf of user on facebook
I get an error (#200) The user hasn't authorized the application to perform this action
I am not sure how with oauth and facebook I add the additional permissions
It would seem with the new rules facebook has implemented the app has to be approved to update user_status not sure if it has to do with the way its set but probably my fault your code seems to be working fine
Here is what I am using for my facebook code https://gist.github.com/naeluh/9f7df425774c2edd7148
thanks again for all your help
 Manuel Lemos - 2014-12-13 02:59:54 - In reply to message 5 from Nick
When you use this class, you should not use Facebook SDK or any other classes to access Facebook API because it does not make sense.
For posting in the Facebook timeline of the user that authorized API access, you need to add the scope publish_actions and send a POST request to the API URL https://graph.facebook.com/me/feed .
 Nick - 2014-12-16 00:41:51 - In reply to message 6 from Manuel Lemos
Ok I will try that would it be something like
$success = $client->CallAPI(
'https://graph.facebook.com/me/feed','POST', array(
"access_token" => $client->access_token,
"message" => 'status'=>$_GET["message"],
"link" => $client->redirect_uri,
"picture" => "",
"name" => "",
"caption" => "",
"description" => ""), array('FailOnAccessError'=>true), $user);
For some reason this does not work ?
thanks
 Manuel Lemos - 2014-12-16 01:20:40 - In reply to message 7 from Nick
That should give you a PHP syntax error. It is better that you enable PHP error logging in php.ini and check the PHP error log file for the messages.
You cannot assign the message and status entry that way in PHP.
Also the access_token or redirect_uri should not be passed to API calls that way. Please check Facebook API parameters documentation for that API call.
|