0

i'm new developer in drupal...sorry for my question..

With my custom module i'm creating a block that show searched tweets with hashtags. I'm using an external library TwitterAPI 1.1. So,i created a function that receive json/tweets,for example

function _mymodule_get_tweet(){

  .....

 $twitter = new TwitterAPIExchange($setting);*

 $response = $twitter->setGetfield($query)->buildOauth($url, $requestMethod)->performRequest();

 $json = json_encode($response,true)
}`

ok... and up here I have no problems .... How can to use this json in a call ajax in ClientSide?? I was thinking of doing the following

  function test_menu () {

    $items = array();

    $items['_mymodule/get_tweets'] = array(

         'page callback' => '_mymodule_get_tweet',

         'access arguments' => array('access content'),

         'type' => MENU_CALLBACK,
 );

  return $items;

} `

to get json with ajax in javascript I'll have to do the following or wrong?

if (Drupal.jsEnabled) {
     $(document).ready(function () {
    $.getJSON(Drupal.settings.basePath + 'mymodule/get_tweets',function(){
              handle data} ....

closed as too broad by Mołot, Free Radical, monymirza, Patrick Kenny, Chaulky Oct 28 '13 at 22:17

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • You have the code - why do you expect us to test it for you, and not try it yourself? Is it too hard for you to simply run it and see if it works? Now if it doesn't, tell us how it failed you. – Mołot Oct 15 '13 at 7:31
  • I am a new developer and this is my first program. Do not ask you to test the program for me. I would just like to know if the way I'm following is the right one. I'm testing several days and I had several problems. I just want to save time by avoiding to follow the wrong path. Then there is any help in the future is only welcome. – Antonio Talamo Oct 15 '13 at 14:18
  • If you had problems, please describe the problems as specifically as you can. Without knowing the problems, it is very difficult to help you. – Patrick Kenny Oct 28 '13 at 1:55
1

There is already a module Twitter Pull which provide the same functionality which you are looking for.

Twitter Pull is a small module, the only purpose of which is to allow super-easy embedding of public twitter data like: a user timeline or twitter search results by hashtag or a search term. The emphasis is on making these very specific tasks as easy and straightforward as possible. The purpose of the module is not to be an end-all solution for Twitter.

I think, there is no need to create custom module for the functionality if there is already contrib module in drupal.org for same functionality.

  • my module is for exercise for a student project. this part is just the beginning of project. I'll complete with other custom options requieredfrom prof. Can you tell me if the way that i'm following is the right? thanks – Antonio Talamo Oct 15 '13 at 12:54
  • @AntonioTalamo, OK. I have to create a custom module. Right now, I am busy, so will check later and will update you. – Jayendra Kainthola Oct 15 '13 at 13:09
  • thanks .. I continue to do tests, but the work is very slow because I have to work on a virtual machine to test the module. – Antonio Talamo Oct 15 '13 at 14:17
  • ..have you an idea what is my problem?..i try to serialize data too but not work..please help me – Antonio Talamo Oct 22 '13 at 13:45
  • @AntonioTalamo, I was busy so could not check your module. – Jayendra Kainthola Oct 23 '13 at 6:04

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