thank you firstly.

yes, some GET requests work normal, such as GET friend_timeline, but the
base url is not like "http://api.twitter.com/*version*
/statuses/friends_timeline.*format*", and it is like "
http://twitter.com/statuses/friends_timeline.xml"; or "
http://twitter.com/timeline";.

now my question is the POST requests, such as POST of statusUpdate method,
how should i do?

+++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++ code info:
//<< main call
                    //|| timeline friend (Twitter / Home)
                    //||
==============================================================================================
                    #if 1    //<< test OK
                    //<< #define TWIT_CURL_TIMELINE_FRIEND_XURL "
http://twitter.com/statuses/friends_timeline.xml";
                    timeline_friend_url_base =
xstrdup(TWIT_CURL_TIMELINE_FRIEND_XURL);
                    timeline_friend_url_base_type = 0;    //<< xml format


twit_func_get_timeline_friend_url(timeline_friend_url_base,
timeline_friend_url_base_type,
                        TWIT_TEST_USER_CONSUMER_KEY,
TWIT_TEST_USER_CONSUMER_SECRET,
                        access_token_key_grant, access_token_secret_grant,
                        &timeline_friend_url);

                    twit_timm_timeline_friend(timeline_friend_url,
&timeline_friend_web_script_first);
                    #endif

                    #if 1    //<< test OK
                    timeline_friend_url_base = xstrdup("
http://twitter.com/timeline";);
                    timeline_friend_url_base_type = 1;    //<< url format


twit_func_get_timeline_friend_url(timeline_friend_url_base,
timeline_friend_url_base_type,
                        TWIT_TEST_USER_CONSUMER_KEY,
TWIT_TEST_USER_CONSUMER_SECRET,
                        access_token_key_grant, access_token_secret_grant,
                        &timeline_friend_url);

                    twit_timm_timeline_friend(timeline_friend_url,
&timeline_friend_web_script_first);

                    #endif
                    //||
----------------------------------------------------------------------------------------------

//<< function define
int twit_timm_timeline_friend(const char *in_timeline_friend_url, char
**out_timeline_friend_web_script)
{
    int debug_trace_flag = 1;
    if (1 == debug_trace_flag || 0 == debug_trace_flag)
    {
        printf("\n\n\n+++++++++++++++++++++++++++++++++++++++++++++++ \n");
        printf("+++++++++++++++++++++++++++++++++++++++++++++++
twit_timm_timeline_friend(...)\n\n\n");
    }

    int rtn_code = 0;

    int web_script_error_code = 0;

    char *timeline_friend_url = xstrdup(in_timeline_friend_url);
    char *timeline_friend_web_script = NULL;


    if (timeline_friend_url)
    {
        timeline_friend_web_script = oauth_http_get(timeline_friend_url,
NULL);

        if (timeline_friend_web_script)
        {
            web_script_error_code =
twit_func_get_error_via_web_script(timeline_friend_web_script);

            if (1 == debug_trace_flag)
            {
                printf("debug trace: timeline_friend_web_script = %s\n",
timeline_friend_web_script);
            }

            if (0 == web_script_error_code)
            {
                *out_timeline_friend_web_script =
timeline_friend_web_script;

                //<< 超 二十条记录的 more 操作, 需另行处理
            }
            else
            {
                rtn_code = web_script_error_code;

                if (1 == debug_trace_flag)
                {
                    printf("debug trace: rtn_code = %d\n", rtn_code);
                }
            }
        }
        else
        {
            rtn_code = -2;
        }

    }
    else
    {
        rtn_code = -1;
    }

    if (1 == debug_trace_flag || 0 == debug_trace_flag)
    {
    printf("\n\n\n----------------------------------------------- \n");
    printf("-----------------------------------------------
twit_timm_timeline_friend(...)\n\n\n");
    }

    return rtn_code;

}


int twit_func_get_timeline_friend_url(const char *in_timeline_friend_url,
int in_timeline_friend_url_type,
                               const char *in_consumer_key, const char
*in_consumer_secret,
                               const char *in_access_token_key, const char
*in_access_token_secret,
                               char **out_timeline_friend_url)
{
    int debug_trace_flag = 1;
    if (1 == debug_trace_flag || 0 == debug_trace_flag)
    {
        printf("\n\n\n+++++++++++++++++++++++++++++++++++++++++++++++ \n");
        printf("+++++++++++++++++++++++++++++++++++++++++++++++
twit_func_get_timeline_friend_url(...)\n\n\n");
    }

    int rtn_code = 0;
    char *timeline_friend_url = NULL;

    if (0 == in_timeline_friend_url_type)        //<< xml格式
    {
        timeline_friend_url = xstrdup(in_timeline_friend_url);
    }
    else if (1 == in_timeline_friend_url_type)    //<< url格式
    {
        timeline_friend_url = xstrdup(in_timeline_friend_url);

         //<< "http://twitter.com/timeline"; or "http://twitter.com/#home"; or
"http://twitter.com"; 都能正常获取到 friend_timeline 信息
        timeline_friend_url = xstrcat(timeline_friend_url, "/");
        timeline_friend_url = xstrcat(timeline_friend_url, "timeline");
    }
    else    //<< 按 xml格式取当前的最新二十条记录
    {
        timeline_friend_url = xstrdup(in_timeline_friend_url);
    }


    timeline_friend_url = oauth_sign_url2(timeline_friend_url, NULL,
OA_HMAC,
                                            NULL, in_consumer_key,
in_consumer_secret,
                                            in_access_token_key,
in_access_token_secret);


    if (1 == debug_trace_flag)
    {
        printf("debug trace: timeline_friend_url = %s\n",
timeline_friend_url);
    }

    *out_timeline_friend_url = timeline_friend_url;


    if (1 == debug_trace_flag || 0 == debug_trace_flag)
    {
        printf("\n\n\n----------------------------------------------- \n");
        printf("-----------------------------------------------
twit_func_get_timeline_friend_url(...)\n\n\n");
    }

    return rtn_code;
}




2010/9/8 Taylor Singletary <taylorsinglet...@twitter.com>

> Hi yuzhujiutian,
>
> Without knowing more about this OAuth library (and also at a disadvantage
> of having very rusty C++ comprehension), I think I'll need to see a
> signature base string for this request to understand what may be going
> wrong. It would be generated somewhere within the chain of code executed in
> the "oauth_http_post" function you use. Are you able to successfully make
> GET requests?
>
> Taylor
>
> On Wed, Sep 8, 2010 at 2:38 AM, yuzhujiutian <yuzhujiut...@gmail.com>wrote:
>
>> api documation, the context is ok? while my app tweet error?
>>
>> http://dev.twitter.com/doc
>>
>> my code info(oauthlib0.8.9, c++):
>>
>> char *url_tmp_2 = NULL;
>> char *prm_tmp_2 = NULL;
>>
>>
>> rtn_code1 = twit_oaum_access_token(TWIT_CURL_ACCESS_TOKEN_URL,
>> TWIT_TEST_USER_CONSUMER_KEY,
>> TWIT_TEST_USER_CONSUMER_SECRET,
>> request_token_key_grant,
>> access_token_secret, direct_token_pin_grant,
>> &access_token_key_grant,
>> &access_token_secret_grant,
>> &access_token_uscreen_name_grant,
>> &access_token_user_id_grant);
>>
>> url_tmp_2 = oauth_sign_url2("http://api.twitter.com/1/statuses/
>> update", &prm_tmp_2, OA_HMAC,
>>                                                NULL,
>> TWIT_TEST_USER_CONSUMER_KEY,
>> TWIT_TEST_USER_CONSUMER_SECRET,
>>                                                access_token_key_grant,
>> access_token_secret_grant);
>>
>> prm_tmp_2 = xstrcat(prm_tmp_2, "&status=snsetest20100906");
>>
>> script_tmp_2 = oauth_http_post(url_tmp_2, prm_tmp_2);
>> printf("xxxx script_tmp_2 = %s\n", script_tmp_2);
>>
>> OUTPUT:
>> +++++++++++++++++++++++++++++++ tweed message test case 2
>>
>>
>> xxxx url_tmp_2 = http://api.twitter.com/1/statuses/update
>> xxxx prm_tmp_2 =
>>
>> oauth_consumer_key=eYpL3h8P2T3RZ7zNIdiA&oauth_nonce=1F05UTyO2quHzVWwYDvSv&oauth_signature_method=HMAC-
>> SHA1&oauth_timestamp=1283937866&oauth_token=172312929-
>>
>> C4kebETEWK2XWA8dCzoSMRcKMDdnecg3be2EqsTr&oauth_version=1.0&oauth_signature=dTKare5TcqE7WO40cRkB2At4Kv0%3D&status=snsetest20100906
>> xxxx script_tmp_2 = <?xml version="1.0" encoding="UTF-8"?>
>> <hash>
>>  <request>/1/statuses/update</request>
>>  <error>Incorrect signature</error>
>> </hash>
>>
>> --
>> Twitter developer documentation and resources: http://dev.twitter.com/doc
>> API updates via Twitter: http://twitter.com/twitterapi
>> Issues/Enhancements Tracker:
>> http://code.google.com/p/twitter-api/issues/list
>> Change your membership to this group:
>> http://groups.google.com/group/twitter-development-talk?hl=en
>>
>
>  --
> Twitter developer documentation and resources: http://dev.twitter.com/doc
> API updates via Twitter: http://twitter.com/twitterapi
> Issues/Enhancements Tracker:
> http://code.google.com/p/twitter-api/issues/list
> Change your membership to this group:
> http://groups.google.com/group/twitter-development-talk?hl=en
>

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk?hl=en

Reply via email to