Why is my ID not posting?


#1

With all the correct files being included, can anybody tell me why the ID isn’t posting?

    ini_set('display_errors', 1);
    require_once('TwitterAPIExchange.php');
    $settings = array(
        'oauth_access_token' => $accesstoken,
        'oauth_access_token_secret' => $accesstokensecret,
        'consumer_key' => $consumerkey,
        'consumer_secret' => $consumersecret
    );
    $url = 'https://api.twitter.com/1.1/direct_messages/destroy.json';
    $postfields = array('id' => $id);
    $requestMethod = 'POST';
    $twitter = new TwitterAPIExchange($settings);
    $response =  $twitter->buildOauth($url, $requestMethod)
                     ->setPostfields($postfields)
                     ->performRequest();
    var_dump(json_decode($response));

The error I receive is:
object(stdClass)#55 (1) { [“errors”]=> array(1) { [0]=> object(stdClass)#56 (2) { [“code”]=> int(38) [“message”]=> string(24) “ID parameter is missing.” } } }

Thanks,
Tom.


#2

So as the error says, for some reason the call believes the id value is not part of the request.

I’ve just run this myself with a modified version of TwitterAPIExchange.php with CURLOPT_VERBOSE set to true and it currently looks to me as if the postfields are not being added to the end of the URL. Still investigating.


#3

Hmm actually I could be mistaken - looks like the code is sending postfields as a curl option and that should be OK. For some reason it doesn’t seem to be picked up on the endpoint, though. Have you tried any other PHP libraries, or have you checked for other folks having a similar issue with TwitterAPIExchange?


#4

Thank’s for your reply Andy, I have not tried this on any other API, just the one associated with my account. Could this have been blocked on my account or something along those lines?

It did work fine a month or 2 ago then stopped all of a sudden. I do have other scripts running in a similar way to this on the same API which auto-retweet, auto-delete tweets and auto-tweet, which are all work perfectly.


#5

The PHP code is not working for me either, so I don’t think it is anything to do with limits or blocking. I can’t see what has changed here, so at the moment I’m a bit baffled. I don’t know whether there are any alternative PHP libraries which would work any better? Do your other scripts also use postfields?


#6

Yes the other do use postfields, however the URL required on those scripts has the ID included, so I tried removing the postfield and it still works without it (for example: https://api.twitter.com/1.1/statuses/destroy/ID.json), so they’re actually not doing anything, this seems to be the reason why this is not working.


#7

Yes my other scripts do use the postfields, however the URLs used with the other sripts ncludes the information needed (such as the ID) in the URL, this is the only script where it does not use ny variables in the URL. I removed the postfields from my other scripts and they still worked without it.

Can you recommend another PHP librariy where I can use a similar script to my current one?

Thanks,
Tom.


#8

Just to chime in here. I had the same issue and have been scratching my head for the past few months. I had a dm spam filter which has been running well over the past year until 2 or 3 months ago when it stopped working. On investigation I’m getting {“errors”:[{“code”:38,“message”:“ID parameter is missing.”}]} too. I didn’t change any code or update the library, but for some reason the Twitter API is ignoring or not receiving the id.

Any updates on this?