Reputation: 217
I'm testing the twitter API (with OAuth) and I have a little problem, I wonder if anyone knows how to fix it, the situation is that at the time I do this (in my redirect.php):
$ Url = $ connection-> getAuthorizeURL ($ token);
header ("Location: $ url");
The request go to twitter, and it's authenticated, but I this return my application back to the home page, and I want to do it in the page I'm doing the OAuth.
Does anyone know the solution?
In short, when users log in, I want the application return it to the same page, not the beginning.
Ah! When I do the log out, all is correct... because I do this (in my clearsessions.php):
session_start();
session_destroy();
$redireccion = $_SERVER['HTTP_REFERER'];
header("Location: $redireccion");
My problem is in the "log in" :-)
Thanks!
Ehm... You can try it here: http://www.joanballestermoragues.com/oauth/test.php As you can see, the login in twitter redirect to http://www.joanballestermoragues.com/oauth/ and I want to redirect to: http://www.joanballestermoragues.com/oauth/test.php
PS: Ah, any can say... "make an index.php and that's all", but no, because this is for another application, it's only a test and I need to do it in another pages than "index" :-)
Thanks again
Upvotes: 0
Views: 2920
Reputation: 52063
You could set your callback URL in your Twitter connection settings and that should fix it. Otherwise, make sure you set the oauth_callback value when requesting the token before you redirect the user to Twitter.
Upvotes: 3
Reputation: 217
In the class TwitterOAuth, I've seen this construct:
function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
if (!empty($oauth_token) && !empty($oauth_token_secret)) {
$this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
} else {
$this->token = NULL;
}
}
And, this line:
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
The method OAuthConsumer() can have another parameter, "$callback_url" (default value is NULL).
May be the solution? I can pass another parameter in this moment. I can put the actual URL... Well I can try it later.
Upvotes: 0