1

I've setup a Twitter app and placed the appropriate Consumer Key and Consumer Secret strings in the settings of admin/config/services/twitter/settings.

I'm able to make twitter 1 api requests just fine, such as drupal_http_request('https://api.twitter.com/1/statuses/oembed.json?id=507185938620219395'); Using api.twitter.com/1.1, however, causes a 215 Bad Authentication error.

Obviously I'm not passing the necessary data to authenticate myself, but how do I go about doing that? All my google searching comes up with Drupal situations utilizing modules which do everything from the UI, or code examples which use php libraries such as Twitteroauth.

I should add that I am running a localserver test site and have setup my app's callback as both http://127.0.0.1:8000/twitter/oauth or the domain name I have setup in etc/hosts on my linux server. Neither seem to help, but both are accepted just fine in the twitter settings.

Lastly, I have been getting the following Notice on admin/config/services/twitter:

Notice: Trying to get property of non-object in user_access() (line 808 of /var/www/twitcher/modules/user/user.module). (as well as lines 820, 821, 827 and 830)

I only began seeing this 2 days ago, and have been unable to figure out exactly what is causing this (I've seen other threads about the same notice, usually relating to Administrative Views, but nothing on the Twitter module).

What is preventing authorization here?

5
  • Thanks for the edit! Has anyone had similar issues before? Commented Oct 8, 2015 at 11:09
  • Using the tutorial at blog.jacobemerick.com/web-development/… , I wrote my own script which was able to make 1.1 requests which respond with recent posts from my own timeline (or that of a specific user). I can't, however, get it to authenticate when I make a request for a specific tweet (by ID or URL). I have tried using oembed.json and show.json, but in both cases I am receiving an " Error Code 32 Could not authenticate you " response. Commented Oct 11, 2015 at 20:14
  • While researching, it seems that the likely problem is my signature base string. It is proposed that the problems are likely: a) The parameters of the base string are not in alphabetical order (mine are) b) One or more of the parameters have been urlencoded twice (mine are only encoded once) I am unable to theorize what else the problem might. Commented Oct 11, 2015 at 20:17
  • I have compared my base signature string with examples found on a few post threads, as well as the Twitter API Official docs, but it seems to be fine. I am, however, able to authenticate on the timeline requests, so I'm not sure what the issue is. Does anyone have any ideas? Commented Oct 11, 2015 at 20:18
  • It can be observed that using an Oauth library, such as twitteroauth, would solve these problems. Furthermore, using this approach isn't really solving the issue through "Drupal" means, such as harnessing the use of a preexisting module. That being said, is there some type of way in which I could take advantage of the Twitter and Oauth modules which would facilitate the programmatic implementation of Twitter API requests on a Drupal site? Commented Oct 12, 2015 at 1:37

1 Answer 1

1

Perhaps not a Drupal solution, but I thought I would update to say that I have settled on using Twitter-API-PHP found here https://github.com/J7mbo/twitter-api-php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.