Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upTweet image is not working for me #76
Comments
This comment has been minimized.
This comment has been minimized.
|
it looks like you haven't defined |
ghost
assigned
themattharris
Sep 12, 2012
This comment has been minimized.
This comment has been minimized.
silvestret
commented
Sep 13, 2012
|
$tweet_text is defined like a parameter in the function function post_tweet($tweet_text,$image) { i have tried of two ways: 'https://api.twitter.com/1.1/statuses/update_with_media.json', version 1.1 and version 1 really dont know which the problem is, but is not possible upload an image for me :( |
This comment has been minimized.
This comment has been minimized.
oosswwaalldd
commented
Sep 13, 2012
|
I think the problem is in the second parameter in the request done of the $connection object: 'https://api.twitter.com/1.1/statuses/update_with_media.json', You must change it to: '1.1/statuses/update_with_media.json', Hope That works |
This comment has been minimized.
This comment has been minimized.
silvestret
commented
Sep 18, 2012
|
no oosswaaaldd, i think we have to use the complete url to do the request to twiiter api not a relative. |
This comment has been minimized.
This comment has been minimized.
mwilber
commented
Sep 26, 2012
|
I'm running into the same issue. v1 of the api (https://upload.twitter.com/1/statuses/update_with_media.json) but v1.1 (https://api.twitter.com/1.1/statuses/update_with_media.json) fails with code 0. |
This comment has been minimized.
This comment has been minimized.
mwilber
commented
Sep 26, 2012
|
Disregard my last comment. The issue was unrelated to the upload url. The error came from a leading @ sign in the status message. In this case my script would tweet the photo to a specific user "@greenzeta here's your photo...". If I modify the message so the @ sign is not leading, "Here's your photo @greenzeta ..." it works. I haven't looked any more deeply than this so I don't know if the issue is with tmhOAuth or twitter itself. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
tharrosinfo
commented
Oct 17, 2012
|
I have been trying to get the update_with_media working for me but did not succeed. I just tried various formats with $image like with and without the {} with and without the @ sign, between " " and between ' ', I tried with status first and then media, and with media first then status, all gave the same response an error occurs updating the status. Just to be clear the following code I tried first and it works, just like it works with OAuth and Twitteroauth for php: require_once($includepath.'tmhOAuth.php'); $code = $connection->request('POST', 'https://api.twitter.com/1.1/statuses/update.json',
Then I tried this code and get a Forbidden 403 response: $image = 'recept001.jpg'; require_once($includepath.'tmhOAuth.php');
Response (I removed codes and unnecessary entries): array(7) { {"errors":[{"code":189,"message":"Error creating status"}]}" " |
This comment has been minimized.
This comment has been minimized.
tharrosinfo
commented
Oct 17, 2012
|
I guess I may have resolved it. Instead of referencing the filename in $image it should hold the binary data so I added: $filename = "recept001.jpg"; then 'media[]' => "{$image};type=image/jpeg;filename={$filename}" , does the trick and the tweet is posted with an image. |
This comment has been minimized.
This comment has been minimized.
tsarma
commented
Oct 18, 2012
|
In my case its still not working, even when I made the $image as binary data as mentioned above. I get response 0!!! |
This comment has been minimized.
This comment has been minimized.
tharrosinfo
commented
Oct 18, 2012
|
add var_dump($connection->response); $connection stands for the variable declared with new tmhOAuth then remove the personal info (tokens) and post the code and the result for review for others to help you |
This comment has been minimized.
This comment has been minimized.
|
glad you got this fixed up and working. |
themattharris
closed this
Oct 27, 2012
This comment has been minimized.
This comment has been minimized.
formariz
commented
Dec 15, 2012
|
Guys, the exemple don't work for me. My code PHP require '../tmhOAuth.php';
require '../tmhUtilities.php';
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => '***************',
'consumer_secret' => '***************',
'user_token' => '***************',
'user_secret' => '***************',
));
$image = 'sol.jpg';
$code = $tmhOAuth->request(
'POST',
'https://api.twitter.com/1.1/statuses/update_with_media.json',
array(
'media[]' => "@{$image};type=image/jpeg;filename={$image}",
'status' => 'Picture time'
),
true,
true
);
var_dump($tmhOAuth->response);
if ($code == 200) {
tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
} else {
tmhUtilities::pr($tmhOAuth->response['response']);
}And response array(6) {
["raw"]=> string(0) ""
["code"]=> int(0)
["response"]=> bool(false)
["info"]=> array(22) {
["url"]=> string(62) "https://api.twitter.com/1.1/statuses/update_with_media.json"
["content_type"]=> NULL
["http_code"]=> int(0)
["header_size"]=> int(0)
["request_size"]=> int(0)
["filetime"]=> int(-1)
["ssl_verify_result"]=> int(0)
["redirect_count"]=> int(0)
["total_time"]=> float(0.936)
["namelookup_time"]=> float(0)
["connect_time"]=> float(0.281)
["pretransfer_time"]=> float(0.936)
["size_upload"]=> float(0)
["size_download"]=> float(0)
["speed_download"]=> float(0)
["speed_upload"]=> float(0)
["download_content_length"]=> float(-1)
["upload_content_length"]=> float(-1)
["starttransfer_time"]=> float(0)
["redirect_time"]=> float(0)
["certinfo"]=> array(0) { }
["redirect_url"]=> string(0) ""
}
["error"]=> string(29) "couldn't open file "sol.jpg" "
["errno"]=> int(26)
}Any idea? |
This comment has been minimized.
This comment has been minimized.
tharrosinfo
commented
Dec 16, 2012
|
Is your $image the name of the image file or the binary data of the file? Because it needs to be the binary data, see above: $filename = "recept001.jpg"; |
This comment has been minimized.
This comment has been minimized.
formariz
commented
Dec 17, 2012
|
i change my code:
$filename = "sol.jpg";
$handle = fopen($filename, "rb");
$image = fread($handle, filesize($filename));
fclose($handle);
$code = $tmhOAuth->request(
'POST',
'https://api.twitter.com/1.1/statuses/update_with_media.json',
array(
'media[]' => "@{$image};type=image/jpeg;filename={$filename}",
'status' => 'Picture time',
),
true, // use auth
true // multipart
);Response: array(6) {
["raw"]=> string(0) ""
["code"]=> int(0)
["response"]=> bool(false)
["info"]=> array(22) {
["url"]=> string(59) "https://api.twitter.com/1.1/statuses/update_with_media.json"
["content_type"]=> NULL
["http_code"]=> int(0)
["header_size"]=> int(0)
["request_size"]=> int(0)
["filetime"]=> int(-1)
["ssl_verify_result"]=> int(0)
["redirect_count"]=> int(0)
["total_time"]=> float(0.702)
["namelookup_time"]=> float(0.156)
["connect_time"]=> float(0.328)
["pretransfer_time"]=> float(0.702)
["size_upload"]=> float(0)
["size_download"]=> float(0)
["speed_download"]=> float(0)
["speed_upload"]=> float(0)
["download_content_length"]=> float(-1)
["upload_content_length"]=> float(-1)
["starttransfer_time"]=> float(0)
["redirect_time"]=> float(0)
["certinfo"]=> array(0) { }
["redirect_url"]=> string(0) ""
}
["error"]=> string(26) "couldn't open file "ÿØÿà" "
["errno"]=> int(26)
}
|
This comment has been minimized.
This comment has been minimized.
carlosacabrera
commented
Feb 13, 2013
|
@formariz try disabling SSL_VERIFYPEER $connection = new tmhOAuth(array(
'consumer_key' => '(hidden)',
'consumer_secret' => '(hidden)',
'user_token' => '(hidden)',
'user_secret' => '(hidden)',
'curl_ssl_verifypeer' => false // <- This guy
)); |
This comment has been minimized.
This comment has been minimized.
|
@formariz you should be setting let's say your file
@carlosacabrera please don't change |
This comment has been minimized.
This comment has been minimized.
formariz
commented
Feb 20, 2013
|
Thank you @themattharris ... Worked perfectly for me. |
silvestret commentedSep 12, 2012
// 'https://upload.twitter.com/1/statuses/update_with_media.json',
array(
'media[]' => "@{$image}",
'status' => $tweet_text
),
true, // use auth
true // multipart
);
I dont know if it is related with @ symbol but i got the next error
{"errors":[{"code":189,"message":"Error creating status"}]}
Thanks in advance