Closed manzoorwanijk closed 7 years ago
I tried both on my localhost as well as my online server, but the result is same...
Why closing?
Sorry, that was my mistake...
A single file would just be like this:
$reply = $cb->media_upload([
'media' => $file
]);
$media_id = $reply->media_id_string;
I just ran this code:
$file = 'bird1.jpg';
\Codebird\Codebird::setConsumerKey('***', '***');
$cb = \Codebird\Codebird::getInstance();
$cb->setToken("***", "***");
$reply = $cb->media_upload([
'media' => $file
]);
var_dump($reply);
And I got this reply:
object(stdClass)[2]
public 'media_id' => int 771069797085880321
public 'media_id_string' => string '771069797085880321' (length=18)
public 'size' => int 191032
public 'expires_after_secs' => int 86400
public 'image' =>
object(stdClass)[3]
public 'image_type' => string 'image/jpeg' (length=10)
public 'w' => int 1280
public 'h' => int 1024
public 'httpstatus' => int 200
public 'rate' =>
object(stdClass)[4]
public 'limit' => string '415' (length=3)
public 'remaining' => string '414' (length=3)
public 'reset' => string '1472675940' (length=10)
Thus, your code should work definitely.
You have this line
$media_ids[] = $reply->media_id_string; // line 41
What is shown if you peek into the server response, like this?
var_dump($reply);
$media_ids[] = $reply->media_id_string; // line 41
Closing due to no further reply from OP.
Hi, I'm trying to update a status with media, but it doesn't work, the media ids are null
the above code shows
Trying to get property of non-object in test.php on line 41
array(2) { [0]=> NULL [1]=> NULL }
and how do I upload a single file?