Coder Social home page Coder Social logo

Comments (11)

MunGell avatar MunGell commented on August 22, 2024

Hi rajjagani,

Could you please post the error message you are receiving from Twitter? I just tried to post and it works fine for me.

Did you grant your application Read/Write access in admin interface (https://dev.twitter.com/apps/) ?

from codeigniter-twitteroauth.

rajjagani021 avatar rajjagani021 commented on August 22, 2024

Yes, i have grant read/write access to my application. the application connect successfully with twitter and return to my website but when i try to store access token than access token include twitter user id along with that as i mention above..so i think this is invalid oauth token..

Now when i am separate the code of access token and used to post a tweet at that time tweet is not post to user account and i am not getting any error in response..

here is my code for post tweet

$this->connection = $this->twitteroauth->create($this->config->item('twitter_consumer_token'), $this->config->item('twitter_consumer_secret'),'Ue1ETxWf6ZFazHZHAioCXKU0DZXcvW1TNWvjeGP', $tweet_data->oauthTokenSecret);

$message=$tweet_data->offerTitle.' @'.$tweet_data->screenName.' - '.site_url('client/claim/index/'.$tweet_data->promId.'/'.$tweet_data->brandId.'/'.$tweet_data->offerId.'/tw');
$data=array(
'status' => $message
);

$content = $this->connection->get('account/verify_credentials');
if(isset($content->error))
{
echo $content->error;
return false;
}
$result=$this->connection->post('statuses/update', $data);
if(!isset($result->error))
{
echo '

Your message is tweet on your twitter account.

';
echo 'Back to Main Page';
}
else
{
echo $result->error;
// Error, message hasn't been published
//redirect(base_url('/'));
}

from codeigniter-twitteroauth.

MunGell avatar MunGell commented on August 22, 2024

Well, from what I see here, you should use full access_token 1095019810-Ue1ETxWf6ZFazHZHAioCXKU0DZXccccTNWvjeGP, not only the second part of it.

Also, I hope you are propagating correct access_token_secret with $tweet_data->oauthTokenSecret, as I don't know what this variable contains.

If this does not help, please post here the error message you are receiving from Twitter.

from codeigniter-twitteroauth.

rajjagani021 avatar rajjagani021 commented on August 22, 2024

Ok, as you said i tried with full access token but still i can't tweet to user account and
$tweet_data->oauthTokenSecret contains the OAuth secret token of user.

the problem is i am not getting any error from twitter while posting but still i can't see my tweet on user account.
here is the code what i write for tweet

$this->connection = $this->twitteroauth->create($this->config->item('twitter_consumer_token'), $this->config->item('twitter_consumer_secret'),$tweet_data->oauthToken, $tweet_data->oauthTokenSecret);

$message=$tweet_data->offerTitle.' @'.$tweet_data->screenName.' - '.site_url('client/claim/index/'.$tweet_data->promId.'/'.$tweet_data->brandId.'/'.$tweet_data->offerId.'/tw');
$data=array(
'status' => $message
);
$result=$this->connection->post('statuses/update', $data);
if(!isset($result->error))
{
echo 'Your message is tweet on your twitter account.';
}
else
{
echo $result->error;
}

from codeigniter-twitteroauth.

rajjagani021 avatar rajjagani021 commented on August 22, 2024

hey i have tried this library(Only for posting tweet) and its works...
this is link
https://github.com/elliothaughin/codeigniter-twitter

what i found they are using a method
set_tokens($tokens) and after that the code is same while i am trying your code i think it is not set the access token properly so it is not posting tweet..

please take a look this library and tell me i am right or not because i am not sure about this. I am trying to solve this and one more thing the connection of app is not working on this library.

Please reply me as soon as possible

from codeigniter-twitteroauth.

MunGell avatar MunGell commented on August 22, 2024

This library you mentioned was updated last time 2 years ago and most probably will not work with present Twitter API.

Unfortunatelly, I cannot reproduce your problem on my installation - my sample controller works fine for auth/posting tweets. Thus, I only can guess what problem you are facing in your code while trying to post a message.

I can recommend you to try sample controller from the repository and if it works - debug your code and find the reason it is not working. Let me know if the sample code not working for you also.

from codeigniter-twitteroauth.

rajjagani021 avatar rajjagani021 commented on August 22, 2024

hey can you please post your sample code here of controller so i can compare with that and figure out or you can mail me the code on [email protected].
It would be very helpful.
Thank you

from codeigniter-twitteroauth.

MunGell avatar MunGell commented on August 22, 2024

Sample code is in the repository:
https://github.com/MunGell/Codeigniter-TwitterOAuth/blob/master/application/controllers/twitter.php

from codeigniter-twitteroauth.

rajjagani021 avatar rajjagani021 commented on August 22, 2024

hey i have try the code as you have mention in above link but still i can't see my tweet on user account and the most difficult part is when i try to debug the code i am not getting any error in twitter response.

but when i try to call LastAPICall() method of your library i get this error

A PHP Error was encountered

Severity: Notice

Message: Undefined property: TwitterOAuth::$last_api_call

Filename: libraries/Twitteroauth.php

Line Number: 56

from codeigniter-twitteroauth.

rajjagani021 avatar rajjagani021 commented on August 22, 2024

hey i fix my problem just one change for catch error in your library

in your library you use
"$result->error" for catching errors but you have to used
"$result->errors" and for printing errors

"echo $result->errors[0]->message"

so, the whole code is...
if(isset($result->errors))
{
echo $result->errors[0]->message;
return false;
}

and Thank you for all your help..

from codeigniter-twitteroauth.

MunGell avatar MunGell commented on August 22, 2024

Thank you for sharing this! I will update the sample controller accordingly.

from codeigniter-twitteroauth.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.