Hi everyone! I need help with my code that tweets images. Please help me with this because I’ve run out of ideas.
The problem is that API returns a mysterious error that is not documented anywhere:
{"message":"Error creating status","code":189}
along with error code 403
I’ve googled a lot, but nothing helped.
Here is my code (I’m using tmhOauth library):
$code = $this->tmhOAuth->request('POST', $this->tmhOAuth->url('1.1/statuses/update_with_media'), array(
'status' => $tweet,
'media[]' => "@"."{$filename}",
true,
true //multipart and auth
));
What I’ve already tried without any success:
- put the file to the same directory and named it 1.png (to ensure that name is not too long), use file with 1kb size, give it 777 permissions. Ensured that fopen($filename) succeeds
- used deprecated API
- tried with raw image instead of file name “{”.$image."};type=image/png;filename={1.png}". Ensured that $image indeed contains raw data.
- ensured that statuses/update works fine
Here is my response. I’ve removed tokens from it:
[params] => Array
(
)
[headers] => Array
(
[Authorization] => OAuth oauth_consumer_key="some_key", oauth_nonce="some_key", oauth_signature="some_key", oauth_signature_method="HMAC-SHA1", oauth_timestamp="some_key", oauth_token="some_key", oauth_version="1.0"
[Expect] =>
)
[auto_fixed_time] =>
[buffer] =>
[config] => Array
(
[user_agent] => tmhOAuth 0.621+SSL - //github.com/themattharris/tmhOAuth
[use_ssl] => 1
[host] => api.twitter.com
[force_nonce] =>
[nonce] => some_string
[force_timestamp] =>
[timestamp] => 1357217282
[oauth_version] => 1.0
[oauth_signature_method] => HMAC-SHA1
[curl_connecttimeout] => 30
[curl_timeout] => 10
[curl_ssl_verifyhost] => 2
[curl_ssl_verifypeer] => 1
[curl_cainfo] =>some_sert_file_that_indeed_exists
[curl_capath] => some_sert_file_that_indeed_exists
[curl_followlocation] =>
[curl_proxy] =>
[curl_proxyuserpwd] =>
[curl_encoding] =>
[is_streaming] =>
[streaming_eol] =>
[streaming_metrics_interval] => 60
[as_header] => 1
[debug] =>
[multipart] =>
)
[method] => POST
[url] => https://api.twitter.com/1.1/statuses/update_with_media.json
[signing_params] => some_string
[auth_header] => OAuth oauth_consumer_key="some_string", oauth_nonce="some_string", oauth_signature="some_string", oauth_signature_method="HMAC-SHA1", oauth_timestamp="some_string", oauth_token="some_string", oauth_version="1.0"
[response] => Array
(
[headers] => Array
(
[date] => Thu, 03 Jan 2013 12:48:03 GMT
[status] => 403 Forbidden
[last_modified] => Thu, 03 Jan 2013 12:48:03 GMT
[x_mediaratelimit_class] => photos
[expires] => Tue, 31 Mar 1981 05:00:00 GMT
[pragma] => no-cache
[x_mid] => some_string
[x_mediaratelimit_limit] => 100
[content_type] => application/json; charset=utf-8
[x_runtime] => 0.14808
[x_transaction] => some_string
[x_frame_options] => SAMEORIGIN
[x_mediaratelimit_reset] => 1357303683
[set_cookie] => some_string; domain=.twitter.com; path=/; HttpOnly
[x_access_level] => read-write
[x_mediaratelimit_remaining] => 100
[cache_control] => no-cache, no-store, must-revalidate, pre-check=0, post-check=0
[x_transaction_mask] => some_string
[server] => tfe
[content_encoding] => gzip
[content_length] => 82
)
[code] => 403
[response] => {"errors":[{"message":"Error creating status","code":189}]}
[info] => Array
(
[url] => https://api.twitter.com/1.1/statuses/update_with_media.json
[content_type] => application/json; charset=utf-8
[http_code] => 403
[header_size] => 1498
[request_size] => 696
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.961157
[namelookup_time] => 0.021136
[connect_time] => 0.203269
[pretransfer_time] => 0.578399
[size_upload] => 115
[size_download] => 82
[speed_download] => 85
[speed_upload] => 119
[download_content_length] => 82
[upload_content_length] => 0
[starttransfer_time] => 0.960736
[redirect_time] => 0
[certinfo] => Array
(
)
[request_header] => POST /1.1/statuses/update_with_media.json HTTP/1.1
User-Agent: tmhOAuth 0.621+SSL - //github.com/themattharris/tmhOAuth
Host: api.twitter.com
Accept: */*
Accept-Encoding: deflate, gzip
Authorization: some_string, oauth_version="1.0"
Content-Length: 115
Content-Type: application/x-www-form-urlencoded
)
[error] =>
[errno] => 0
)
)