0

Add contact using ContactAPI

I am using contactAPI to add a new contact. And I did this:
1. Get the keys by registering my application.
2. Get request token - successfully
3. Redirect to authorization page - completed successfully
4. Extract verifier and exchange request token to access token - completed successfully
5. Now when I try to add a new contact by doing the following, it returned: Method not implemented (501)!!!
To add contact I did this:
a. Build a json contact object
b. Sign my request (HMAC-SHA1)
c. Add oauth info in the Authorization header
(this include realm which is set to "yahooapis.com")
d. Add json contact object to the POST body
e. Then do a POST to "http://social.yahooapis.com/v1/user/{GUID}/contacts"
NOTE: {GUID} = the guid of the user who authorized this access.
I have these questions:
- Add contact call always return 501 saying method not implemented. Does it mean that it currently does not support Add contact operation???
- There is some confusion on the "AccessToken" parameter that I got when I make a call to exchange request token for an access token.
Do I have to encode this parameter just like all other paramters when POSTing to this "http://social.yahooapis.com/v1/user/{GUID}/contacts"???

I would really appreciate a prompt response as it feels like I hit a wall and not making any progress ..

by
18 Replies
  • hi,

    i have a few questions for you, the answers may help get to the bottom of this issue. 501 on POST /contacts doesn't sound right...

    is your oauth consumer key authorized for read/write contacts api access?

    does GET on the contacts endpoint work for you?

    thanks.

    QUOTE (Naseem @ Feb 15 2010, 09:12 AM) <{POST_SNAPBACK}>
    I am using contactAPI to add a new contact. And I did this:
    1. Get the keys by registering my application.
    2. Get request token - successfully
    3. Redirect to authorization page - completed successfully
    4. Extract verifier and exchange request token to access token - completed successfully
    5. Now when I try to add a new contact by doing the following, it returned: Method not implemented (501)!!!
    To add contact I did this:
    a. Build a json contact object
    b. Sign my request (HMAC-SHA1)
    c. Add oauth info in the Authorization header
    (this include realm which is set to "yahooapis.com")
    d. Add json contact object to the POST body
    e. Then do a POST to "http://social.yahooapis.com/v1/user/{GUID}/contacts"
    NOTE: {GUID} = the guid of the user who authorized this access.
    I have these questions:
    - Add contact call always return 501 saying method not implemented. Does it mean that it currently does not support Add contact operation???
    - There is some confusion on the "AccessToken" parameter that I got when I make a call to exchange request token for an access token.
    Do I have to encode this parameter just like all other paramters when POSTing to this "http://social.yahooapis.com/v1/user/{GUID}/contacts"???

    I would really appreciate a prompt response as it feels like I hit a wall and not making any progress ..
    0
  • QUOTE (Nick @ Feb 18 2010, 09:15 AM) <{POST_SNAPBACK}>
    hi,

    i have a few questions for you, the answers may help get to the bottom of this issue. 501 on POST /contacts doesn't sound right...

    is your oauth consumer key authorized for read/write contacts api access?

    does GET on the contacts endpoint work for you?

    thanks.


    Hi Nick,
    Thanks for looking into this issue.
    a. I have re-verified that my consumer key has read/write access to contacts.
    b. Not even Get works .. when I send "oauth parameters" in "authorization headers" for GET .. I got "403"
    NOTE:
    I have successfully exchanged request token for an access token. So I have a valid access token. I signed my request using HMAC-SHA1.

    -Naseem
    0
  • What is the exact Normalized Base Signature String you used to create your HMAC signature?

    What is the exact error response you received from the Contact API call?

    Please cut-and-paste both items here.
    0
  • QUOTE (joec @ Feb 19 2010, 11:31 PM) <{POST_SNAPBACK}>
    What is the exact Normalized Base Signature String you used to create your HMAC signature?

    What is the exact error response you received from the Contact API call?

    Please cut-and-paste both items here.


    This is how normalized base signature string is construction for computing signature:
    - Request URI: http://social.yahooapis.com/v1/user/uGUID/contacts
    - signature base =
    RFC3986.Encode("POST") + "&" + RFC3986.Encode("http") + RFC3986.Encode("://")
    + RFC3986.Encode("social.yahooapis.com")
    + RFC3986.Encode("/v1/user/uGUID/contacts")
    + "&"
    + RFC3986.Encode(normalizedQueryParam)
    WHERE
    normalizedQueryParam is:
    queryparams: oauth_consumer_key, oauth_signature_method, oauth_timestamp, oauth_nonce, oauth_version, oauth_token, format
    these parameters are RFC3986 (both key and value are encoded) encoded and sorted into lexicographic order (by key and value)
    NOTE: format is yahoo specific additional query param .. and is format=json

    When I do a get the exact error I got is 401. When oauth is sent in authorization header.
    When I do a post (where new contact is sent in post body as json), I recieve 501 method not implemented error.
    0
  • QUOTE (Naseem @ Feb 20 2010, 03:23 PM) <{POST_SNAPBACK}>
    This is how normalized base signature string is construction for computing signature:
    - Request URI: http://social.yahooapis.com/v1/user/uGUID/contacts
    - signature base =
    RFC3986.Encode("POST") + "&" + RFC3986.Encode("http") + RFC3986.Encode("://")
    + RFC3986.Encode("social.yahooapis.com")
    + RFC3986.Encode("/v1/user/uGUID/contacts")
    + "&"
    + RFC3986.Encode(normalizedQueryParam)
    WHERE
    normalizedQueryParam is:
    queryparams: oauth_consumer_key, oauth_signature_method, oauth_timestamp, oauth_nonce, oauth_version, oauth_token, format
    these parameters are RFC3986 (both key and value are encoded) encoded and sorted into lexicographic order (by key and value)
    NOTE: format is yahoo specific additional query param .. and is format=json

    When I do a get the exact error I got is 401. When oauth is sent in authorization header.
    When I do a post (where new contact is sent in post body as json), I recieve 501 method not implemented error.


    You have provided the method by which the signature base string is generated, but not the actual result of that. Can you cut-and-paste that here? Without the actual query string or http header that is sent to the server there is no way to debug what's wrong.

    For example, this is the result of a properly normalized base string (with consumer_key and oauth_token scrambled):
    CODE
    GET&http%3A%2F%2Fsocial.yahooapis.com%2Fv1%2Fuser%2FGFERT4345GRDQ7K7H656BOGFFG
    %2Fcontacts%3Bcount%3D5&format%3Djson%26oauth_consumer_key%3Ddfe9fdjg19adfdwBN
    VRuVkwzJmQ9WVdrOWFrOW5hMADFDSF324NHbzlNQjadfQGSFGSuc3VtZXJADFFdsadFEFiIHb--
    %26oauth_nonce%3D265297829%26oauth_signature_method%3DHMAC-SHA1
    %26oauth_timestamp%3D1267043189%26oauth_token%3DA%253DvMFCBA.a5QadflkajdfklljA
    SDFADSFADdf45mFdXaFgKwgCQCTSTcYITr5u63a3p7hYvGmyO8.MnAgYwa28ZHMt20P5KQHkAkSoJn
    Nw9x_kSvZ2rMiu9tZMcj6.wfj0J0vhB6cQmwFnxkJJCmyW1tH68unn5FNOPK9HFeF_hUCYiOehtPDQ
    qAGWx8q59ZE5ZTfbOfRCaElCJL5modilFb3SZTdQZpY6HnbJERpXNO8FActQu9hHtxaiXINnJM_RU4
    3z1H6A3vgDgWLPpwYX_suy9TAxr2sXStcdBQtHV9ILL5PAk7HapBM2FdNJhvN1exlFi7gFr8ZCh1cf
    ibPxrHwiBn6Azy6viQJEzLLAnHsYh3eEvOmLU1Lm_IUIqr5sa.oqIBly092NTPVtR8fJz7any54D0I
    .AG0uKjv1JedReiaoiN4hdN9y5nqY7z._Xw5MZ_2mTbGaHXAUmUn_ogyzY.q0GQYbI4A7hZp7j56Ix
    L.I7Z4EehN.5fLtL9XBFXCt1slgm4GtGy.N9xHyzCMB9feuTwpg3rTQ6hLfAMbskw43svjBFUSGyeu
    IqjIlt.8W5amKIm1Jljz3tyKfkNAzTNgrT6NSjkRQ8NXMq9y6oqe3IHgNvbqndNB82gXT2nNtEuhQB
    w3t95UrijWpgU69NPE4lFkiiVOol6AYuec_MyTJPCu093AnVt0.oYJyehxG4rgWmadUH6gQ6U9V9oy
    VghFg52pyH9hyp_vjFg6UxDQ0esBkmAfHck8lbEtjkujYgyWvnDFEww34FADh-
    %26oauth_version%3D1.0


    Please provided the full body of the 401 and 501 responses. The body will tell you further what may be wrong. For example, this is the body of a response that tells you that a token has expired (in pretty-printed JSON format)

    CODE
    {
    "error": {
    "lang": "en-US",
    "description": "Please provide valid credentials. OAuth oauth_problem=\"token_expired\", realm=\"yahooapis.com\""
    }
    }
    0
  • QUOTE (joec @ Feb 24 2010, 12:52 PM) <{POST_SNAPBACK}>
    You have provided the method by which the signature base string is generated, but not the actual result of that. Can you cut-and-paste that here? Without the actual query string or http header that is sent to the server there is no way to debug what's wrong.

    For example, this is the result of a properly normalized base string (with consumer_key and oauth_token scrambled):
    CODE
    GET&http%3A%2F%2Fsocial.yahooapis.com%2Fv1%2Fuser%2FGFERT4345GRDQ7K7H656BOGFFG
    %2Fcontacts%3Bcount%3D5&format%3Djson%26oauth_consumer_key%3Ddfe9fdjg19adfdwBN
    VRuVkwzJmQ9WVdrOWFrOW5hMADFDSF324NHbzlNQjadfQGSFGSuc3VtZXJADFFdsadFEFiIHb--
    %26oauth_nonce%3D265297829%26oauth_signature_method%3DHMAC-SHA1
    %26oauth_timestamp%3D1267043189%26oauth_token%3DA%253DvMFCBA.a5QadflkajdfklljA
    SDFADSFADdf45mFdXaFgKwgCQCTSTcYITr5u63a3p7hYvGmyO8.MnAgYwa28ZHMt20P5KQHkAkSoJn
    Nw9x_kSvZ2rMiu9tZMcj6.wfj0J0vhB6cQmwFnxkJJCmyW1tH68unn5FNOPK9HFeF_hUCYiOehtPDQ
    qAGWx8q59ZE5ZTfbOfRCaElCJL5modilFb3SZTdQZpY6HnbJERpXNO8FActQu9hHtxaiXINnJM_RU4
    3z1H6A3vgDgWLPpwYX_suy9TAxr2sXStcdBQtHV9ILL5PAk7HapBM2FdNJhvN1exlFi7gFr8ZCh1cf
    ibPxrHwiBn6Azy6viQJEzLLAnHsYh3eEvOmLU1Lm_IUIqr5sa.oqIBly092NTPVtR8fJz7any54D0I
    .AG0uKjv1JedReiaoiN4hdN9y5nqY7z._Xw5MZ_2mTbGaHXAUmUn_ogyzY.q0GQYbI4A7hZp7j56Ix
    L.I7Z4EehN.5fLtL9XBFXCt1slgm4GtGy.N9xHyzCMB9feuTwpg3rTQ6hLfAMbskw43svjBFUSGyeu
    IqjIlt.8W5amKIm1Jljz3tyKfkNAzTNgrT6NSjkRQ8NXMq9y6oqe3IHgNvbqndNB82gXT2nNtEuhQB
    w3t95UrijWpgU69NPE4lFkiiVOol6AYuec_MyTJPCu093AnVt0.oYJyehxG4rgWmadUH6gQ6U9V9oy
    VghFg52pyH9hyp_vjFg6UxDQ0esBkmAfHck8lbEtjkujYgyWvnDFEww34FADh-
    %26oauth_version%3D1.0


    Please provided the full body of the 401 and 501 responses. The body will tell you further what may be wrong. For example, this is the body of a response that tells you that a token has expired (in pretty-printed JSON format)

    CODE
    {
    "error": {
    "lang": "en-US",
    "description": "Please provide valid credentials. OAuth oauth_problem=\"token_expired\", realm=\"yahooapis.com\""
    }
    }


    Okay, here is the requested information:
    - I am now just trying to make it work with GET contacts
    - exact signature base I used to (NOTE: I removed consumerKey intentionally):
    GET&http%3A%2F%2Fsocial.yahooapis.com%2Fv1%2Fuser%2FYRLUBNM3DUUDOPLU23O6HHOC7E%2Fcontacts&oauth_consumer_key%3DMyEncodedConsumerKeyGoesHere%26oauth_nonce%3D9898e322-ea97-46f3-a6ac-d230734a60e3%26oauth_signature_method%3DHMAC_SHA1%26oauth_timestamp%3D1271272074%26oauth_token%3DA%253D3_ngKGWejwR2lk0dRhcKIWAFDLrUKClb5TUWZJCb2GjZiyuDwQjlPKnkkid.rUfpK8wduzkpW8f4
    evthJmhMf9pzp6gy4j6Oyw5S.r3_NMWT.yuQsX1M5UB9DOzsI5afXks5zjJ6fu4UGqI6EcPmwPsXRD75e
    fJTFRNuk3meTQS3VyAkFVNudoocfLwGldBGpV_cbnwtPbP4y6EEafy5iyqj05luLd5VabXgQdGiceq0vG
    zsFEGdCNzVeWBy3fcAWuYxWSJPkE_yj_iy9QLMpO7Z47zvgNrepWJUON4u3SBvBJD2EMGx9hM8wlU8TlS
    WhaL77tT8X1ZTOWFOjGekf8IzCJUENTxZ4a947tO4.spVtwz7PUG7Suu4v_._rmii0pe603UF_qE14t1Q
    Q6iYbFBHuFfk0VIh_qu_LnDINU2f8TFZR5AejcxOMuqwUScIay..ghapUR9N8U6uVG5VhkG.Yys3z8bru
    RCEC6oqeiZoM7BulQq_TAFtSYCSI5vw_J83kvJ9_5bo1H_Bm0_JjBzh4L.tjWqSaKa78vFihVRLuOwk.h
    R6q2UXmtTBjdJghZsUbG5vncIcdlipEKdc6OMFlTuy85kRP.5iksIgkWZ3BmhKZMjHrDjIuUZ_.RsOaxa
    nDXlCyEKY8Is7A0zwl7Z2DGUBw2i2DJJYd98B6HGmUMMdBI5mDvjmlxvV48I_0yA-%26oauth_version%3D1.0
    - And here is the exact request headers sent:
    Authorization: OAuth realm="yahooapis.com", oauth_consumer_key="MyConsumerKeyGoesInHere", oauth_signature_method="HMAC_SHA1", oauth_timestamp="1271272074", oauth_nonce="9898e322-ea97-46f3-a6ac-d230734a60e3", oauth_version="1.0", oauth_token="A%3D3_ngKGWejwR2lk0dRhcKIWAFDLrUKClb5TUWZJCb2GjZiyuDwQjlPKnkkid.rUfpK8wduzkpW8f4ev
    thJmhMf9pzp6gy4j6Oyw5S.r3_NMWT.yuQsX1M5UB9DOzsI5afXks5zjJ6fu4UGqI6EcPmwPsXRD75efJ
    TFRNuk3meTQS3VyAkFVNudoocfLwGldBGpV_cbnwtPbP4y6EEafy5iyqj05luLd5VabXgQdGiceq0vGzs
    FEGdCNzVeWBy3fcAWuYxWSJPkE_yj_iy9QLMpO7Z47zvgNrepWJUON4u3SBvBJD2EMGx9hM8wlU8TlSWh
    aL77tT8X1ZTOWFOjGekf8IzCJUENTxZ4a947tO4.spVtwz7PUG7Suu4v_._rmii0pe603UF_qE14t1QQ6
    iYbFBHuFfk0VIh_qu_LnDINU2f8TFZR5AejcxOMuqwUScIay..ghapUR9N8U6uVG5VhkG.Yys3z8bruRC
    EC6oqeiZoM7BulQq_TAFtSYCSI5vw_J83kvJ9_5bo1H_Bm0_JjBzh4L.tjWqSaKa78vFihVRLuOwk.hR6
    q2UXmtTBjdJghZsUbG5vncIcdlipEKdc6OMFlTuy85kRP.5iksIgkWZ3BmhKZMjHrDjIuUZ_.RsOaxanD
    XlCyEKY8Is7A0zwl7Z2DGUBw2i2DJJYd98B6HGmUMMdBI5mDvjmlxvV48I_0yA-", oauth_signature="SignatureGoesInHere"
    Accept: application/json

    This is what the response code is:
    The remote server returned an error: (401) Unauthorized.
    Exception.Status = ProtocolError
    Response Headers returned are:
    Vary: Accept-Encoding
    Age: 0
    Transfer-Encoding: chunked
    Connection: keep-alive
    Content-Type: application/json
    Date: Wed, 14 Apr 2010 19:16:35 GMT
    Server: YTS/1.18.4
    Via: HTTP/1.1 r5.ycpi.mud.yahoo.net (YahooTrafficServer/1.18.4 [cMsSf ])
    WWW-Authenticate: OAuth oauth_problem="signature_method_rejected", realm="yahooapis.com"

    Does this make any sense??
    0
  • Ok. you have two problems.
    1. Your query parameter is double encoded. It should read oauth_signature_method=HMAC-SHA1 and not oauth_signature_method%3DHMAC-SHA1. That's why you're getting a "signature method invalid" error.
    2. You're passing OAuth tokens both in your get parameter list and in your HTTP header. Don't do that. It's either or.

    I have a Yahoo OAuth Tutorial that prints out the actual request and response for each step of the OAuth flow, starting with get_request_token and ending in an actual contact or yql call. All you have to do is edit in your keys and run it on the command line. You can change the $passOAuthInHeader variable to true or false to see how things change when you pass the oauth stuff in the header vs as query parameter.
    0
  • QUOTE (joec @ Apr 16 2010, 07:37 AM) <{POST_SNAPBACK}>
    Ok. you have two problems.
    1. Your query parameter is double encoded. It should read oauth_signature_method=HMAC-SHA1 and not oauth_signature_method%3DHMAC-SHA1. That's why you're getting a "signature method invalid" error.
    2. You're passing OAuth tokens both in your get parameter list and in your HTTP header. Don't do that. It's either or.

    I have a Yahoo OAuth Tutorial that prints out the actual request and response for each step of the OAuth flow, starting with get_request_token and ending in an actual contact or yql call. All you have to do is edit in your keys and run it on the command line. You can change the $passOAuthInHeader variable to true or false to see how things change when you pass the oauth stuff in the header vs as query parameter.


    I'm wonderding if yahoo contact api 's working. Your article's very helpful but I found that link use in step 2 is https://api.login.yahoo.com/oauth/v2/get_request_token is always dead. Any body has exact answer for this problem? Thank you very much
    0
  • QUOTE (LAM @ Apr 19 2010, 03:35 AM) <{POST_SNAPBACK}>
    I'm wonderding if yahoo contact api 's working. Your article's very helpful but I found that link use in step 2 is https://api.login.yahoo.com/oauth/v2/get_request_token is always dead. Any body has exact answer for this problem? Thank you very much


    Did you run the script php getreqtok.php or did you cut-and-paste that url directly into the browser? I ran the script just now and it works. The latter will not work unless you have all the right query parameters present.

    If the script does not work, what is the output? Does ping api.login.yahoo.com work for you?
    0
  • QUOTE (joec @ Apr 16 2010, 07:37 AM) <{POST_SNAPBACK}>
    Ok. you have two problems.
    1. Your query parameter is double encoded. It should read oauth_signature_method=HMAC-SHA1 and not oauth_signature_method%3DHMAC-SHA1. That's why you're getting a "signature method invalid" error.
    2. You're passing OAuth tokens both in your get parameter list and in your HTTP header. Don't do that. It's either or.

    I have a Yahoo OAuth Tutorial that prints out the actual request and response for each step of the OAuth flow, starting with get_request_token and ending in an actual contact or yql call. All you have to do is edit in your keys and run it on the command line. You can change the $passOAuthInHeader variable to true or false to see how things change when you pass the oauth stuff in the header vs as query parameter.



    Hello! I've tried out your tutorial, but it looks like I'm doing something wrong because I get an error ("Please provide valid credentials. OAuth oauth_problem=\"additional_authorization_required\", realm=\"yahooapis.com\"").

    Here is my request header:

    Authorization: OAuth
    realm="http://yahooapis.com/",
    oauth_version="1.0",
    oauth_nonce="773704453",
    oauth_timestamp="1275066000",
    oauth_consumer_key="dj0yJmk9ZWFleGw2MXV3ZlFXJmQ9WVdrOWNFeDBZMVpHTkhVb
    WNHbzlNVE16TlRFMU16UTJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeD04Nw--",
    oauth_token="A%3DfS1PHw.eoiLilVBiqh7IKj5DW_nxn10qkGysHDGHzmSeSZ9ypx8V8X.3
    r.xTnrqdeU3tgAAe28xc0BE14uocpydlURCUQrnlKHoE4RrxC2fHpI55fFZ39ej8pyoQA23O.7
    83Q6GLXNRQu1ELZAb2D3XrGZU3BjwpEDrbl18BtNCDPfeGU4oVJM_lhOnAbMLVZqKER
    lyXzVxZHGCR39X_cwZpVX5wzu9a5V0jO7x24MBuNvBB_bruoX0bHiskZg4KSL9aQElKSj97
    O7BWLP1DhxE5KshEJsdVvA362OvcgrW5OL5whcCeVL3zvOyzsHKEBVHOogw5_KysE_D
    wqMV3_.XozVXlxAxs82N5lZZ8prsf2DUgJu_Kp7C0tnZ94d_inSz2j297PVhOOC.UU51A7O7
    tVWfT_tE6MMXcMEb6pVeEAFmIvdGZIjxVZObZz8FBywXiJ6CQvU5K2x_Gjjtr9ZNfJVSNldovd
    iZiKczFHQqzm1VzKL_Ql1dYTDEaRibSFap_RwrxppvlDgbQRVq_rZiO1vRBV5vlEbTZy0kR9
    kBAyKbIQU6ucq_1o4ndcjtA9Y3e47K09rY02ikUUBeylpFVSC3AHm1UH3TDXZDpp091oEf
    ZL87yDTHFWYgmGv7UnyWld4WbqUTCwdd5Ua8G2uH8exUTBVE9fHYGkm4jemFLJMiC
    uh.DuTyxmuU_EjIe__8Rsg--",
    oauth_signature_method="HMAC-SHA1",
    oauth_signature="3APaMlh29VQQrE5pHXU8NMVGFYI%3D"

    Do you know what is wrong?

    Thanks!
    0
  • Thanks for the response.
    I realized that oauth_signature_method value was incorrect.
    I was passing "HMAC_SHA1", instead of "HMAC-SHA1" .. once I fixed that I am now able to get contacts list without any issues.
    But still the problem remains with POST (while I try to add a new contact).
    According to "Social API Explorer":
    "HTTP POST and PUT operations require permission from Yahoo!. You can make a request through the YDN Contact Form. "
    I am wondering if that is why I am getting this error:
    "he remote server returned an error: (501) Not Implemented"
    when I try to do a POST.
    If that is the case, I used that form to request that permission but I am still waiting and have not heard anything back.

    NOTE:
    The reason why I did not realize signature method name is incorrect is because I use the exact same code to request token, access token etc and those requests worked fine without any problem. I do not understand why?
    0
  • QUOTE (Naseem @ Apr 19 2010, 10:49 AM) <{POST_SNAPBACK}>
    Thanks for the response.
    I realized that oauth_signature_method value was incorrect.
    I was passing "HMAC_SHA1", instead of "HMAC-SHA1" .. once I fixed that I am now able to get contacts list without any issues.
    But still the problem remains with POST (while I try to add a new contact).
    According to "Social API Explorer":
    "HTTP POST and PUT operations require permission from Yahoo!. You can make a request through the YDN Contact Form. "
    I am wondering if that is why I am getting this error:
    "he remote server returned an error: (501) Not Implemented"
    when I try to do a POST.
    If that is the case, I used that form to request that permission but I am still waiting and have not heard anything back.


    Hi, now we need to see the raw request+header and the raw response that generates the 501 error.
    I tried posting to contact and it works. The only time I get a 501 error is if the endpoint is incorrectly (some typo), or if the HTTP method is not really POST but something else. This is why we need to see the raw traffic to debug further.
    0
  • Yes, today I've test and v2/reqest_get_token working well.Thank your reply very much.
    At present I use C# Oauth Lib to access and get request token but no success because result from response always is unauthorized. I wondering if yahoo contact api support other language as c# when i use steps in oauth online document.? Because when reading contact php sdk i notice that browser agent to pass parameter to make request to request token is hardcode is "PHP sdk something". Is there posibility yahoo contact api prevents agents except yahoo contact api support current (PHP,FLASH)?
    0
  • Contact API does support c#
    I implemented it all myself without using any of the libraries and it is working fine.
    The only problem that I now have is POSTing to contacts resource. Which return 501. Looks like some special permission need to be requested from Yahoo to use PUT and POST against this resource. I have made that request and am just waiting on them to get back.
    0
  • I will provide you raw request headers and content ..
    But what about this:

    I created my application and setup this application to have both read/write access to Contacts. Where does the following requirement fit in:
    According to "Social API Explorer":
    "HTTP POST and PUT operations require permission from Yahoo!. You can make a request through the YDN Contact Form. "

    From this it seems like I need to request additional permissions from Yahoo in order to POST/PUT, is this correct??
    This seems to be the case, looks like I can GET but I do not have Write permission .. that is why POST failed with 501.
    Can you please explain the meaning of this additional requirement as stated on Social API explorer page.
    0
  • QUOTE (Naseem @ Apr 20 2010, 01:51 PM) <{POST_SNAPBACK}>
    I will provide you raw request headers and content ..
    But what about this:

    I created my application and setup this application to have both read/write access to Contacts. Where does the following requirement fit in:
    According to "Social API Explorer":
    "HTTP POST and PUT operations require permission from Yahoo!. You can make a request through the YDN Contact Form. "

    From this it seems like I need to request additional permissions from Yahoo in order to POST/PUT, is this correct??
    This seems to be the case, looks like I can GET but I do not have Write permission .. that is why POST failed with 501.
    Can you please explain the meaning of this additional requirement as stated on Social API explorer page.


    You don't have to do anything manual with Yahoo to enable write access to contacts.
    I have added a postcontact.php script to my source tree.
    http://github.com/joechung/oauth_yahoo/

    Use that as an example of the headers and post body you need to send to get contact add working. Note that you should not include the post body in the signature generation, and the content-type should be application/json or xml, and not application/x-www-form-urlencoded.
    0
  • Thanks a lot for all your help.
    Looking at your sample .. I found out "contact" data was incorrectly formed. After I fixed that it is now working fine. I can POST to contacts using ContactAPI
    0
  • The problem is in the YOSAccessToken implementation, every time you get the token from the dictionary stored in NSUserDefaults, is calculating expired date with the current date and then never expires, that is the error...

    Replace the code with this and works like a charm.

     + (YOSAccessToken *)tokenFromStoredDictionary:(NSDictionary *)tokenDictionary
    {
        NSInteger tokenExpires = [[tokenDictionary valueForKey:@"tokenExpires"] intValue];
        NSInteger authExpires = [[tokenDictionary valueForKey:@"authExpires"] intValue];
        NSDate *dateTokenExpires = [tokenDictionary objectForKey:@"tokenExpiresDate"];
        NSDate *dateAuthExpires = [tokenDictionary objectForKey:@"authExpiresDate"];
    
        YOSAccessToken *theToken = [[YOSAccessToken alloc] initWithKey:[tokenDictionary valueForKey:@"key"]
                                                             andSecret:[tokenDictionary valueForKey:@"secret"]];
        [theToken autorelease];
        [theToken setGuid:[tokenDictionary valueForKey:@"guid"]];
        [theToken setSessionHandle:[tokenDictionary valueForKey:@"sessionHandle"]];
        [theToken setTok<enExpires:tokenExpires>];
        [theToken setAu<thExpires:authExpires>];
        [theToken setTokenEx<piresDate:dateTokenExpires>];
        [theToken setAuthEx<piresDate:dateAuthExpires>];
    
        if([tokenDictionary valueForKey:@"consumer"]) {
            [theToken setConsumer:[tokenDictionary valueForKey:@"consumer"]];
        }
    
        return theToken;
    }
    
    #pragma mark -
    #pragma mark Public
    
    - (NSMutableDictionary *)tokenAsDictionary
    {
        NSMutableDictionary *tokenDictionary = [[NSMutableDictionary alloc] init];
        [tokenDictionary autorelease];
        [tokenDictionary <setObject:self.key> forKey:@"key"];
        [tokenDictionary <setObject:self.secret> forKey:@"secret"];
        [tokenDictionary <setObject:self.guid> forKey:@"guid"];
        [tokenDictionary <setObject:self.sessionHandle> forKey:@"sessionHandle"];
        [tokenDictionary setObject:[NSNumber numb<erWithInt:self.tokenExpires>] forKey:@"tokenExpires"];
        [tokenDictionary setObject:[NSNumber numb<erWithInt:self.authExpires>] forKey:@"authExpires"];
        [tokenDictionary setObject:[NSDate dateWithTimeInterva<lSinceNow:self.tokenExpires>] forKey:@"tokenExpiresDate"];
        [tokenDictionary setObject:[NSDate dateWithTimeInterva<lSinceNow:self.authExpires>] forKey:@"authExpiresDate"];
    
    
        if(self.consumer) [tokenDictionary <setObject:self.consumer> forKey:@"consumer"];
    
        return tokenDictionary;
    }
    
    
    0

Recent Posts

in Contacts