CakePHP and posting to certain twitter account - php

I used cake php with twitter datasource to post some info on a certain twitter account. Twitter changed the authentication method towards oauth.
I can't find an example of a cakephp app, where a certain message is posted in a certain twitter account. For example when publishing an article in the site, I want site's twitter account to get updated.
I have read some examples but in these the user accessing the page gets redirected to twitter to be authenticated and to publish something on his/hers account, which is not want I want.
Anybody has an example on that?
thanks a lot.

Have a look at Using one access token with OAuth in the Twitter documentation, it describes a single-user use case and avoids the redirect.

Hm, I do not know if this helps you, but do you read the article from neil crook? cakephp-oauth-extension-to-httpsocket
I think for the first time the user get redirected to twitter to authorize the application... After that you save ‘oauth_token’ and ‘oauth_token_secret’ for further access to the Twitter Api...
But i must say that i have not tried it yet...
Maybe the tipp from David Yell in this question thread LINK helps

Related

How read facebook timeline

I need to read facebook timeline but I don't know how I can do. I don't find anything!! I use this library:
https://github.com/facebookarchive/facebook-php-sdk
Anyone can help me to suggest a tutorial or other something?
Here you can access the FB Developer pages.
They have examples and manuals for a variety of programming languages and tools.
Here's a few things you will need in order to read an FB timeline:
Facebook assigns a unique and fairly long ID to any account, whether profile or fan page. Users, however, don’t use this ID to identify pages. So the first thing to do in order to read a timeline is match the public name of the page (or user) to the underlying Facebook ID.
Getting the ID of the account for which you intend to read the timeline is only the first step. You also need to be authenticated to access the feed.
Once acquired, the access token can be saved to a cookie and used for every further operation until it expires.
You can find the whole article on this link.
There are a few code examples on the page as well written in C#.
Hope this helps.

Listing Tweets from a protected account?

I have a protected twitter account but I want to be able to show a list of my most recent tweets on my website.
I'm prepared to dive in to the twitter docs but I just wanted a heads up to know if its possible?
Would my script have to autenticate with my account or is there a way to allow access to my twitter account from a particular IP?
Thanks
Yes, definitely possible. I don't know if there is a simpler solution, but one way would be to create a new app on Twitter which your account authorizes. In the authorization process, Twitter will give you access tokens for your specific account. Store your access tokens in a database. Read your tweets from a PHP widget say, which uses the Twitter PHP API, and uses your access tokens to display it.
When you are retrieving your tweets, it doesn't matter if it is protected or not as long as you have authorized that specific application.
Simply put, the widget that displays your tweets is a Twitter application that you have authorized. (one-time authentication)
Well I don't think so you can read anything from Protected account.
I was reading few articles about the same issue and here is the alternative solution if you would like to give a try. (I personally didn't tried it so leaving up to you to give shot)
http://www.ehow.com/how_6474863_protected-twitter-updates.html

How to remove 'via app' when posting on facebook page feed

When posting to the page wall (feed) through my application, under the post contents facebook adds '20 minutes ago *via my_app*'. This is a problem for my company, since they don't want the fans knowing the posting is done through an application, thus losing the personal touch.
Is there any way to lose the '*via my_ap*p' part of the post? These are some of the things I have tried:
I have given every possible permission on the page admin user, including 'manage_pages'
Have tried with the token returned from graph api me/accounts for that page / Impersonating pages
Please tell me, short of making a bot to do the whole thing, is there any way to do this through the facebook api.
Thank you for any help you can provide.
If you don't want the people to see which company you are, then Facebook is the wrong platform for you!
I'm pretty sure, you also would violate the terms of Facebook (Developer).
See what your competitors are doing. The largest company in this business has named their app "Publisher". When users click on this a page will open up that doesn't say anything about who created the app - actually it doesn't say anything at all. You could also use the name "Publisher" for your Facebook publishing app - in Facebook app names don't have to be unique.

twitter api get user email

I am curious to know how to authenticate the user with twitter and after successful login, i need the email of the user... how can it be done?
Heard that twitter does not support openid.... any alternate solution ?
Just to update this issue, it is now possible (from April 2015).
You can send a support ticket to Twitter to whitelist your app to make it possible to ask for an email. Then, after an user connects their account, you need to make a GET request to verify credentials with the "include_email" option set to true.
It is explained in more detail in the second link.
Check out this article and try this search.
Twitter supports OAuth, and I am myself having trouble with it (I am writing a Python script app). A switch to xAuth is possible.
"Mobile and desktop applications are also given the opportunity to use xAuth, a means to exchange a login & password for an access token. To use xAuth, send a request to api#twitter.com with plenty of details about your application and why xAuth is the best choice for it." - http://dev.twitter.com/pages/auth
Late answer, but I hope it will help someone.
There is no way to obtain the email from the API.
See the doc there : Twitter doc
Other post relating that : SO post
The link provided in tarantinofan's answer is quite old, but the principles are there, as an explanation on how OAuth works.
Twitter API cannot provide Email address so you cannot get it from twitter API
(See Doc of twitter api)
you can get it from user after log in or try another way

how can I fetch private tweets using a PHP application

I want to show my latest tweet in a web page. My tweets are private for some reason and I should login to Twitter. I know that the basic HTTP authentication was deprecated in August 2010. How can I provide authentication in my PHP code to fetch private tweets (or userTimeline if I'm not mistaken)?
I've searched but unfortunately didn't find anything useful! :( Thanks in advance for your help!
Jan, I heard about ZendFramework while I was searching for the answer but It's complicated for me.
I found the solution here that illustrates how I can use OAuth based on Abraham’s Twitter OAuth library.
The key note is that I stored my 'oauth_access_token' in a database or somewhere else immediately after first login via my twitter credential. Then I remove the code which allow users to login to twitter and reuse stored credential to fetch the latest tweet by using $user->status->text variable.
It's a geeky job. It maybe has some potential security flaws but I'm not sure! ;)
By the way, Thanks a lot for your reply, Jan! :D
Authentication to Twitter is done via OAuth. A pretty simple way to access your Twitter account with PHP is using the latest version of ZendFramework. It will be required to register your app on twitter, which allows you to generate an oauth token. This token can be used to access your private twitter feed.
See documentation of Zend_Service_Twitter and Zend_Oauth_Consumer.
Here http://framework.zend.com/manual/en/zend.oauth.introduction.html you will find a pretty good introduction of using Zend OAuth together with twitter (note that the address used in the $config array has to be api.twitter.com/oauth and NOT twitter.com/oauth )
However, you can also make your Tweets public in your twitter account settings (Settings -> Account -> Tweet Privacy -> Uncheck "Protect my tweets"). Then your tweets will be available on the public timeline (not at once, you may have to wait a bit).
Hope that helps!
-Jan

Categories