{"action":"created","issue":{"url":"https://api.github.com/repos/jublonet/codebird-php/issues/137","labels_url":"https://api.github.com/repos/jublonet/codebird-php/issues/137/labels{/name}","comments_url":"https://api.github.com/repos/jublonet/codebird-php/issues/137/comments","events_url":"https://api.github.com/repos/jublonet/codebird-php/issues/137/events","html_url":"https://github.com/jublonet/codebird-php/issues/137","id":110188608,"number":137,"title":"status update with media issue","user":{"login":"nirmalthumber","id":12571525,"avatar_url":"https://avatars.githubusercontent.com/u/12571525?v=3","gravatar_id":"","url":"https://api.github.com/users/nirmalthumber","html_url":"https://github.com/nirmalthumber","followers_url":"https://api.github.com/users/nirmalthumber/followers","following_url":"https://api.github.com/users/nirmalthumber/following{/other_user}","gists_url":"https://api.github.com/users/nirmalthumber/gists{/gist_id}","starred_url":"https://api.github.com/users/nirmalthumber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nirmalthumber/subscriptions","organizations_url":"https://api.github.com/users/nirmalthumber/orgs","repos_url":"https://api.github.com/users/nirmalthumber/repos","events_url":"https://api.github.com/users/nirmalthumber/events{/privacy}","received_events_url":"https://api.github.com/users/nirmalthumber/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-07T09:49:16Z","updated_at":"2015-10-07T09:58:44Z","closed_at":null,"body":"I am using this example : https://github.com/jublonet/codebird-php#uploading-media-to-twitter\r\n\r\nFor media update on twitter .previously it was working fine . But today when i try to upload media .. it will update simple image two times.\r\n\r\nHere is the example.\r\nHere i try to upload two images . But when it will update to twitter total 4 images updated\r\n![pasted_file](https://cloud.githubusercontent.com/assets/12571525/10334133/dd4b2ee4-6d1a-11e5-9fdf-175c807cdd88.png)\r\n\r\nApply this code for media_upload .\r\n\r\n     foreach ($media_files as $file) {\r\n         // upload all media files\r\n      $reply = $cb->media_upload([\r\n        'media' => $file\r\n      ]);\r\n       // and collect their IDs\r\n      $media_ids[] = $reply->media_id_string;\r\n       }\r\n\r\nIt is returning only 2 media_id_string.\r\nBut when i apply below code for status update with media .\r\n\r\n$media_ids = implode(',', $media_ids);\r\n\r\n      // send tweet with these medias\r\n     $reply = $cb->statuses_update([\r\n         'status' => 'These are some of my relatives.',\r\n         'media_ids' => $media_ids\r\n       ]);\r\n       print_r($reply);\r\n\r\nHere only 2 media_id_string pass . But when i saw status on twitter . 4 image updated .\r\n![pasted_file](https://cloud.githubusercontent.com/assets/12571525/10334133/dd4b2ee4-6d1a-11e5-9fdf-175c807cdd88.png)\r\n\r\nI tried this multiple times .Every time getting the same result two times images updated .. Is there anything changes from twitter side???"},"comment":{"url":"https://api.github.com/repos/jublonet/codebird-php/issues/comments/146136657","html_url":"https://github.com/jublonet/codebird-php/issues/137#issuecomment-146136657","issue_url":"https://api.github.com/repos/jublonet/codebird-php/issues/137","id":146136657,"user":{"login":"jublo","id":6348321,"avatar_url":"https://avatars.githubusercontent.com/u/6348321?v=3","gravatar_id":"","url":"https://api.github.com/users/jublo","html_url":"https://github.com/jublo","followers_url":"https://api.github.com/users/jublo/followers","following_url":"https://api.github.com/users/jublo/following{/other_user}","gists_url":"https://api.github.com/users/jublo/gists{/gist_id}","starred_url":"https://api.github.com/users/jublo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jublo/subscriptions","organizations_url":"https://api.github.com/users/jublo/orgs","repos_url":"https://api.github.com/users/jublo/repos","events_url":"https://api.github.com/users/jublo/events{/privacy}","received_events_url":"https://api.github.com/users/jublo/received_events","type":"User","site_admin":false},"created_at":"2015-10-07T09:58:44Z","updated_at":"2015-10-07T09:58:44Z","body":"The issue is that you add the media ids to the array multiple times. Try to add the following line of code **before** your line `foreach ($media_files as $file) {`:\r\n\r\n```php\r\n$media_ids = array();\r\n```\r\n\r\nThis will reset the array.\r\n\r\nHowever, in the end make sure that you only upload images once, in order not to waste traffic. You might want to walk through your code step by step, so you find out why the `foreach ($media_files as $file)` loop is called multiple times."}}