Twitter Oauth Delphi 7 home_timeline getting 401 unauthorized - delphi

I am using Oauth for Delphi from ChuckBeasley.com
I am able to get a request token, then call with my callback url and put in my credentials.
I then get redirected correctly to my callback url in a TEmbeddedWB component.
I then get an access token (at least I believe I am) since screen_name and user_id come back in the response.
When I try and pull my home_timeline it gives me a 401 unauthorized as a response.
What can I be doing wrong?
Thanks
David

try my implementation, it doesn't use the OAuth library, but my own from scratch
http://eden.fm/2011/02/27/twitter-library-for-delphi/

You're also welcome to use my open-source Twitter component (TTwitter for Delphi) which is being developed as part of a "complete" suite of Social Networking components (if there is such a thing as "Complete" in terms of social networking). You can find it at: http://www.simonjstuart.com/delphi-stuff/ttwitter/
It's using the ChuckBeasley OAuth library, only I have fixed it (so it ACTUALLY WORKS). In the very least you'll be able to reverse engineer my component to suit your needs. It's an open beta (far from complete at its current released stage) but it handles timelines perfectly (including unicode characters).
Enjoy and good luck!

Related

Programatically get New Access Token for oAuth 2.0 in Postman

In Postman, I am able to successfully request a new token using the GUI. I'm wondering how to do this programatically. Or at least see the HTTP request that Postman is making. I've tried viewing it by monitoring the network traffic in Chrome, and with Wireshark, but without success. Thank you
well, OAuth2 is quite a big subject and you are not really providing a lot of details.
Postman is just a client, it creates requests based on the data you gave it so you don't need to monitor anything, you should know how you set it up and then simply mirror that in whatever language you want. Look at headers and post data specifically.
All I can do is point you to an extensive article I wrote on OAuth2, it shows a complete implementation, how to use Postman to create the correct requests and then how to write code which makes it all work.
If you don't use dot net, you can still understand all the concepts and it should be trivial to do the same thing using a different language.
https://eidand.com/2015/03/28/authorization-system-with-owin-web-api-json-web-tokens/

How to get results with twitter search api?

I wish to get tweets with a keyword. But There is no result with any keyword.
http://search.twitter.com/search.json?q=summer
How to get results with Twitter Search API?
Version 1 of the twitter API has been deprecated and is being removed. Not sure how you can miss the giant warnings on the twitter dev site ;) This means simple code like the above will not work any more.
So, you now need to make authenticated requests (OAuth) using the 1.1 API, and it's nowhere near as simple as just doing a (in PHP) file_get_contents(http://search.twitter.com/ ...).
I couldn't see any server-side languages you use from your profile, but I wrote a lengthy post explaining the issue (with pictures) and how to use a php library to perform authenticated requests.

Google Docs upload works on some accounts but not others

I have written a client in C to upload files to Google Docs, I get an authentication token, and use it for the upload. However, I have 4 Google accounts, the upload worked on 2 accounts, but not the other 2. And now, it only works on one account.
On authentication, all accounts behave the same, and ClientLogin issues an "Auth=xxx" token. I use the token 100% successfully on one Google account, it used to work on another, and has never worked on the other 2.
The only error is "HTTP/1.1 401 Token invalid".
One account used to work, and now does not, which does not make much sense. The ClientLogin calls never seem to ask for a CAPTCHA.
Currently I can't invest the time to move to the Drive API, and that may present the same issues anyway.
Any thoughts?
Thank you
Garry
Try them individually first, if this works you can start combining untill all 4 works,
doing it step by step is the way to succes, I can't help you with programming code, according to the fact that I'm just a noobie :) tho I thought myself PHP by just doing it step by step, if you got 1 done, then it's just copy/paste and change abit :)
Goodluck tho :)
You should move your code away from ClientLogin and use OAuth 2.0 instead. You didn't mention what language your script uses but Google has some samples for performing OAuth 2.0 at:
https://developers.google.com/google-apps/documents-list/#authorizing_requests_with_oauth_20
and
https://developers.google.com/api-client-library/
Jay

Twitter api statuses/destroy api 401 error

I'm authenticating with OAuth getting my request token, authorizing, doing POST to get the AccessToken and then pulling my user_timeline.xml
At this point I try and call the destroy api on a particular status id and it returns a 401 unauthorized.
I am able to take the url and the parameters out and call this through Fiddler2 and it works, but using it in a Delphi app with Indy V10 component, doing a POST it's giving this 401 still.
What can I be missing?
Thanks,
david
If I can figure this out this app is good to go, very frustrating.
Please help!
Figured it out. Finally ran a .NET version of code, ran Fiddler2 to see what it did and noticed the Authorization Header. I then had to find a reference to this in regards to the Indy Components to figure it out. You have to add CustomHeaders with a specific format.
You may wanna try my implementation with ICS, supports Unicode as well
http://eden.fm/2011/02/27/twitter-library-for-delphi/

Wall on FaceBook

i would like to post a message on facebook wall (standard friend/group's wall) not the Apps. using delphi, i could log-in but i dont know how to post a message on it. any suggestion?
I have never used Delphi so im not sure about the language structure
but facebook API is basically HTTP Requests, you should be able to build a class that upon instanation you would authorize your app and then have a set of methods that publish data via HTTPRequest and validate the response
Heres something you may wish to look at:
Facebook emailer in delphi via CakeMail: http://www.facebook.com/note.php?note_id=17522112271
And how to post via HTTP:
http://developers.facebook.com/docs/reference/api/post
It is possible.
If you're able to login you can use a sniffer to take a look for the details of how it is accomplished by Facebook itself when you do it withing a browser (kind of reverse engineering). Wireshark is the best tool for me.
Look and take your time to understand what's going on between your browser and the servers when you post messages to your friend's wall.
Once you understand the details, you can mimic the exact same behavior from your Delphi program to get the same results, for example with the TidHTTP or TidTCP components.
Facebook is AJAX intensive: series of HTTP GET/POST operations without full page refreshes.
Don't forget you're mimicking a undocumented and internal communication mechanism. Facebook or any other target site may change it's internal's and broke your program compatibility anytime.
Remember this kind of program may be prohibited... read the facebook agreement's for further details.
delphibook is a Delphi library to support Facebook applications.
Two possible links that may provide some guidance? They are not in delphi, but I assume the api would be similar to javascript/php ?
http://daipratt.co.uk/using-fb-api-to-make-a-full-post-to-a-users-wall/
http://blog.theunical.com/facebook-integration/5-steps-to-publish-on-a-facebook-wall-using-php/

Resources