and thanx for reading, I'm trying to use Oauth with zend 2 by following this tutorial
but it seems Expired and all goes wrong with me, the last code I tried in my controller is:
$config = array(
// all these urls from details tab for my application
'siteUrl' => 'https://api.twitter.com/oauth/token',
'requesttokenUrl'=> 'https://api.twitter.com/oauth/request_token',
'accesstokenUrl' => 'https://api.twitter.com/oauth/access_token',
'authorizeUrl' => 'https://api.twitter.com/oauth/authorize',
'consumerKey' => 'API key from twitter api Keys tab',
'consumerSecret' => 'THE API secret from twitter api Keys tab'
);
// fetch a request token
$token = $consumer->getRequestToken();
// persist the token to storage
$_SESSION['TWITTER_REQUEST_TOKEN'] = serialize($token);
// redirect the user
$consumer->redirect(array('oauth_token' => urlencode(serialize($token))));
and this leads me to this page:
I don't know If this code is right and why I get this result.
is there any tutorial to lead me to do it right, or can any one help me with this?
any idea is appreciated, Thanx in advance.
Related
I'm using y0lk package to help me with OAuth1 and ETSY App, I managed to get the temporary credentials, but can't get my hand on Access tokens.
here's what I do :
$client = new Etsy([
'identifier' => '*********************',
'secret' => '*********',
'scope' => 'listings_r transactions_r',
'callback_uri' => 'http://*********.loc/slider/'
]);
$tempCred = $client->getTemporaryCredentials();
$tmpSecret = $tempCred->getSecret();
$tmpId = $tempCred->getIdentifier();
// Redirect to Etsy Autorisation login page
$redirect_url = $client->getAuthorizationUrl($tempCred);
$accessTokens = $client->getTokenCredentials($tempCred, $tmpId, $_GET['oauth_verifier']);
Ok, I don't know how to do, because to obtain the oauth verifier ( and do the $_GET['oauth_verifier']), I have to go by the login page, and then, to get the access token, I need my temp credentials, but to get then I 'll have to go again by new Etsy and this is why I always got the token revoked error..
I'm beginner, in PHP and with API, if someone see other mistakes in my way to do this, feel free to point them out for me :)
Thank you for your time.
I have a website that uses the Twitter API (verrsion 1.1) with PHP and Zend framework 1 for validating the user name that is entered into a text input by a user of the application.
I created the app on Twitter and generated the Consumer Key (API Key), Consumer Secret (Secret API), Access Token and Access Token Secret.
General permissions: Read, write, and direct messages
Tokens permissions: Read and write
My PHP code for the authentication with Twitter is:
$config = array(
'version' => '1.1',
'signatureMethod' => 'HMAC-SHA1',
'callbackUrl' => 'http://example/main/twitter',
'siteUrl' => 'https://api.twitter.com/oauth',
'requestTokenUrl'=> 'https://api.twitter.com/oauth/request_token',
'accessTokenUrl' => 'https://api.twitter.com/oauth/access_token',
'authorizeUrl' => 'https://api.twitter.com/oauth/authorize',
'consumerKey' => self::$_consumeKey,
'consumerSecret' => self::$_consumeSecret
);
$session = new Zend_Session_Namespace('OAUTH_TWITTER');
$consumer = new Zend_Oauth_Consumer( $config );
$token = $consumer->getRequestToken();
$session->request_token = serialize($token);
$consumer->redirect();
When this code is executed, in the line:
$token = $consumer->getRequestToken();
returns the following error:
Could not retrieve a valid Token response from Token URL:
error code="215" Bad Authentication data.
I do not know what I did because previously was working perfectly. I researched for 2 weeks and still can not find the solution. I tried to create the application again, regenerate keys and tokens and change the time zone of my server to UTC but has not been solved.
If you need more information about me, please let me know.
I appreciate any information you can give me. Regards.
PD: sorry by my bad english
I have a website..previously when I was uploading a new post in my blog..It was getting posted to twitter automatically. But since the new version of OAuth system..It no longer works...Can anybody help me to sort out what to change?
My code is :
'Twitter'=>array(
'enabled' => true, //set to false to shut off twitter integration
'username' => 'blogspott', //your twitter.com username
'password' => 'W3Sw9OpW6HvZYl', //your twitter.com pasword
'consumer_key' => 'TdQS15VHBdZNIrQ7RPqVQ',
'consumer_secret' => 'B2Xe5h3lHXVXUgoCAxgAIdJDTeBf6AywRoGiTwB7I',
'oauth_token' => '283508422-FkiIyZq2tpx1PQOyBLyWyomXY9OdMKxxSKGcg9d3',
'oauth_token_secret' => '548kxcZCvhytdRkJ405QeWONvMyXNEpSZszIMEYU4W4',
'tweet'=>'#%POST% for just %URL-TO-POST% %LINK%',
// Bit.ly / URL Shortening
// Within your Tweets, auto-append short URLs i.e., bit.ly/s8dJksm, to save on space.
// Sign up for an API account at http://bit.ly, and place the information
// for that account in the box below
'short_url'=>array(
'append_short_url'=>false,
'short_url_provider'=>'bit.ly', // current option: bit.ly only (default), more soon!
'bitly'=>array(
'login' => 'o_78ocugrkqtf',
'api_key' => 'R_734dbe3be47605c405f4e19ec35eb617'
),
)
),
I am using the right keys here..I've double checked it.
Twitter did not change its OAuth system recently. It is not concerned by the controversial Twitter API 1.1. So verify that you are doing it just like Twitter asks and that you do not use deprecated endpoints (Twitter removed some of them recently).
I am able to get the Records of the UserVoice by calling and Unauthorized Requests but now i want to create and Update things in which i need OAuth but i am unable to find the UserVoice's PHP Implementation of OAuth and Create/Update/Delete with UserVoice API is there anyone can guide me how to Implement such thing??
We have quite recently worked on this and released an OAuth-based library which makes it a bit easier to access UserVoice API from a PHP version 5 application.
An example on how to create a ticket using an access token for user#example.com:
<?php
require_once('vendor/autoload.php'); // Using Composer
$client = new \UserVoice\Client('subdomain-name', 'API KEY', 'API SECRET');
$access_token = $client->login_as('user#example.com');
$result = $access_token->post("/api/v1/tickets", array(
'ticket' => array(
'state' => 'open',
'subject' => 'PHP SDK',
'message' => "Would you have any OAuth example for PHP?"
)
));
?>
Despite the fact that the library is still under development, I believe it's already useful to you. See the blog post and more examples like responding to tickets as an account owner at:
http://developer.uservoice.com/docs/api/php-sdk/
Disclaimer,
Please pardon grammatical syntax.
I'm using the simple linkedin php library that is offered on the linkedin's site. I have followed their instructions and have successfully collected the users oauth-token and oauth-secret. Those 2 pieces of information have been stored in a database. I would like to know how make an offline oauth call, but im having trouble finding more information on the oath-verifier. This is the code that i have so far.
include('../../php/linkedin/linkedin_3.2.0.class.php');
include '../../php/global.settings.php';
$API_CONFIG = array(
'appKey' => LINKEDIN_APP_KEY,
'appSecret' => LINKEDIN_APP_SECRET,
'callbackUrl' => NULL
);
$linkedin = new LinkedIn($API_CONFIG);
$linkedin->request_token = "4e1e5ede-1de4-4eba-ba33-d3d37cbe67ff -FAKE";
$linkedin->access_token = "82b2c333-1075-441b-a51f-657196bf507w -FAKE";
$search_response = $linkedin->search("?company-name=facebook&count=10");
var_dump($search_response);
Temporarily I'm inserting the keys their on my own trying to bottleneck the behavior. Again, the authentication was successful, but my attempt to make a call to the users profile when the user is offline is a failure. I believe it is because im missing the oauth-verifier, but i don't believe that the oauth-verifier is necessary to make an offline call.The code pretty much breaks without any errors (if that is possible). I Have not tempered with the linkedin library nor there are any errors in the global.settings.php.
If you have already stored the user's access token then all you need to do is feed the access token in to the library and make your calls. From the demo file, something along the lines of:
$API_CONFIG = array(
'appKey' => LINKEDIN_APP_KEY,
'appSecret' => LINKEDIN_APP_SECRET,
'callbackUrl' => NULL
);
$linkedin = new LinkedIn($API_CONFIG);
$linkedin->setToken(array(
'oauth_token' => $token,
'oauth_token_secret' => $secret
));
$search_response = $linkedin->search("?company-name=facebook&count=10");
var_dump($search_response);