0

Meme API for commandline applications

Suppose I have a PHP based command line (CLI) application using which I want to post to Yahoo MEME. How will I do that? OAuth works for web application. I want to post to my own MEME account so I know the username and password.

Note that I understand how OAuth works and about API keys etc. My question is how to use MEME API (based on YQL) with a command line application without invoking the web browser for authentication (since I know my username and password).

To be more specific, I want to automatically post all my Twitter posts (Tweets) to Yahoo Meme.

3 Replies
  • Hi,

    actually OAuth works for both web and non-web applications. There are two things to care about in order to do the later:
    1. When you register a new developer key, make sure to select Client/Desktop application in the register form;
    2. Set the oauth_callback to oob (Out-Of-Bands);


    Differently from the Web flow, you will explicitly ask the user to authorize your app, hence the user will need a browser to do this. Then your application will need the oauth_verifier in order to complete the oauth flow (the authorization page will provide this oauth_verifier to him).

    Once you have it, it goes as usual: you can keep the token in a durable medium and refresh the token once it expires.

    Hope that helps, let me know if you have any further questions.

    ~dsouza
    0
  • Hi dsouza,

    I have a Client/Desktop app and has auth_callback=oob. I wonder why it keeps crashing. I did some trace and here's what I've got:

    CODE
    [Session started at 2009-10-13 20:53:46 +0800.]
    2009-10-13 20:53:48.505 Test[2065:207] urlRequest <NSMutableURLRequest https://api.login.yahoo.com/oauth/v2/get_request_token?oauth_callback=oob>
    2009-10-13 20:53:48.507 Test[2065:207] rspError Error Domain=NSURLErrorDomain Code=-1012 UserInfo=0xf1a990 "Operation could not be completed. (NSURLErrorDomain error -1012.)"
    2009-10-13 20:53:48.507 Test[2065:207] urlResponse (null)
    objc[2065]: FREED(id): message release sent to freed object=0xf1af00


    I found that NSURLErrorDomain error -1012 means NSURLErrorUserCancelledAuthentication with reference to this document: http://developer.apple.com/mac/library/doc.../reference.html

    The libraries that am using are from http://github.com/yahoo/yos-social-objc

    Any idea on what am I missing? Thanks for your help.

    -Jerome


    QUOTE (dsouza @ Oct 7 2009, 03:35 PM) <{POST_SNAPBACK}>
    Hi,

    actually OAuth works for both web and non-web applications. There are two things to care about in order to do the later:
    1. When you register a new developer key, make sure to select Client/Desktop application in the register form;
    2. Set the oauth_callback to oob (Out-Of-Bands);


    Differently from the Web flow, you will explicitly ask the user to authorize your app, hence the user will need a browser to do this. Then your application will need the oauth_verifier in order to complete the oauth flow (the authorization page will provide this oauth_verifier to him).

    Once you have it, it goes as usual: you can keep the token in a durable medium and refresh the token once it expires.

    Hope that helps, let me know if you have any further questions.

    ~dsouza
    0
  • QUOTE (Jerome @ Oct 13 2009, 05:30 AM) <{POST_SNAPBACK}>
    Hi dsouza,

    I have a Client/Desktop app and has auth_callback=oob. I wonder why it keeps crashing. I did some trace and here's what I've got:

    CODE
    [Session started at 2009-10-13 20:53:46 +0800.]
    2009-10-13 20:53:48.505 Test[2065:207] urlRequest <NSMutableURLRequest https://api.login.yahoo.com/oauth/v2/get_request_token?oauth_callback=oob>
    2009-10-13 20:53:48.507 Test[2065:207] rspError Error Domain=NSURLErrorDomain Code=-1012 UserInfo=0xf1a990 "Operation could not be completed. (NSURLErrorDomain error -1012.)"
    2009-10-13 20:53:48.507 Test[2065:207] urlResponse (null)
    objc[2065]: FREED(id): message release sent to freed object=0xf1af00


    I found that NSURLErrorDomain error -1012 means NSURLErrorUserCancelledAuthentication with reference to this document: http://developer.apple.com/mac/library/doc.../reference.html

    The libraries that am using are from http://github.com/yahoo/yos-social-objc

    Any idea on what am I missing? Thanks for your help.

    -Jerome


    Hi,

    first of all, really sorry for the delay to reply you. I can't help with objective C, but I could eventually help with C or C++.

    Anyway, here we go.

      If that is the request URL, it is missing a `few' parameters. It is only defined the oauth_callback, but you also need to set oauth_nonce, oauth_timestamp, oauth_consumer_key, oauth_signature and oauth_signature_method. So the initial request should be similar to this:
      https://api.login.yahoo.com/oauth/v2/
      get_request_token?oauth_nonce={random string}
      &oauth_timestamp={seconds since 1/1/1970}
      &oauth_consumer_key={your consumer key}
      &oauth_signature_method=plaintext
      &oauth_signature={the plaintext signature}
      &oauth_version=1.0
      &oauth_callback=oob


    Probably that is why you got it aborted because of authorization missing. It is intriguing why the library didn't set those parameters though. You can also send these in a HTTP header, namely Authorization. Could you check if the library is not sending these parameters in a header field? Both should work, using them in the query string may make it easier do debug.

    Let me know how it goes, hope that helps,
    Regards,
    0
This forum is locked.

Recent Posts

in Meme-General discussion