Publishing a node from an SMS message ???

drupalina - June 29, 2009 - 04:14
Project:SMS Framework
Version:6.x-1.0
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi,

I'm looking for a solution that would allow my users to send SMS messages from their mobile phones, which will be automatically published as nodes on my site. Exactly as we see on Twitter and many other microblogging websites.

I am wondering if SMS Framework is the right module for this kind of feature???

If not, do you plan to develop such a feature?

I'm also wondering if people would be able to send photos and videos taken with their mobile phones and publish it directly on my website?

Thank you!

#1

benone - July 22, 2009 - 20:36

Hi,
I think SMS Framework has this option.

I have easier question:
How to create node using PHP ? I have setup Gammu server. I have some scripts there.
I'd like to write PHP script which connect to my Drupal site (on different server) and add node to this site.

Is that possible ?

#2

brian_c - July 22, 2009 - 21:10

node_save() should work, if you create a properly formatted $node object and pass it.

#3

benone - July 22, 2009 - 23:04

yeah, you're right. its quite easy! :)

here links for other interested ppl:
http://drupal.org/node/67887
http://www.unibia.com/unibianet/node/29

#4

benone - July 22, 2009 - 23:05

hmmm. the only question. how to send those data to this script ?
GET , POST , XML POST ?

GET is not a good idea coz message is too long ... am I right ?

#5

brian_c - July 23, 2009 - 02:19

Well if you're just doing this for SMS, isn't the max message size 160 chars? That would fit fine in a GET request.

POST would of course be more flexible for larger data. I'd go with POST if you have any intention of using the code in the future for stuff other than SMS requests.

[Edit: Sorry, it was the original poster asking about SMS, not you)

#6

benone - July 23, 2009 - 02:33

Yeah, my only problem is I am beginer PHP coder and can write only using GET and Lynx browser to send this SMS to drupal script.
Do you know how to do it using POST ? Do I need Lynx to send a request ?
Do not apologize I was asking about sms also, I know how to receive SMS and trigger a script after that. The only problem I dont know how to send this that from one server (with gsm module) to another (with drupal and my php script with node_save().

Thx, ben

#7

brian_c - July 23, 2009 - 19:58

You could code the POST request yourself using fopen() and such (see this thread for some example code: http://www.webmasterworld.com/php/3164561.htm), or you could use the cURL library (see http://answers.yahoo.com/question/index?qid=20070414080209AA3QiTt)

#8

benone - July 24, 2009 - 01:00

Hey Brian, thank you. I will use this method. Only need to find out how to do this in a separate process.
Now I use Lynx and GET method, because I know how to exec() Lynx without waiting to the end of connection. The screipt can go to the end and do not wait untail data will be send. Lynx is doing that separately. It's quite good , coz script can receive next data and run another lynx process.

Actually I think if I prepare this POST script in separate file I can run it in the same way like lynx :), cant I ?

Thanks again for your co-op.

B.

#9

brian_c - July 24, 2009 - 05:32

Try this: http://stackoverflow.com/questions/124462/asynchronous-php-calls

You could also use an AJAX approach, submitting the POST with Javascript. This is pretty easy with jQuery.

#10

benone - July 24, 2009 - 11:19

Hey this is it. Thanks, what I noticed PHP can be the same adventure as Drupal is :)

#11

benone - July 24, 2009 - 11:22

I forgot:) - Thanks again !

#12

benone - July 24, 2009 - 14:47

Ok Brian, tell me to shut up and I'll finish this thread :)
Or lets go further..

What we have now:

1) machine A receive SMS: "JOHNNY Hello World!"
2) machine A posts it to machine B (Drupal hosting server) - POST request to nodesms.php
3) PHP script - nodesms.php - using node_save() creates new node where the title is tel number and body SMS text and date automaticaly created and..... author <- here I stopped :) , the author is Anonymous.

Wouldn't be great if the user was: johnny ? :)

Now I can do it stiffly, what I did, I add: $node->uid = 4; to my nodesms.php script and I have new node where the author is johnny.

Thats cool, but what when the user Johnny doesnt exist ?

What I'd like to do now:

Use some next Drupal API function which let me create an Array with registered users. I can extract first word from SMS, then write

while ($users[] == 'johnny') {

$uid = some_drupal_api_function_which_can_check_uid_using_username('johnny');
$node->uid = $uid;
}

TAA DAA :) done. What you think ?

B.

#13

benone - July 24, 2009 - 18:23

ok, I found out how to do this. But I am SELECTING directly from Drupal database:
mysql_query("SELECT * FROM users WHERE name='$username'")

have no idea how user_load() Drupal API function works.

B.

#14

brian_c - July 24, 2009 - 22:27

<?php
$user
= user_load( array( 'name' => $username ) );
if(
$user ){
 
$node->uid = $user->uid;
}
?>

Should work

#15

benone - July 24, 2009 - 23:05

Yes, indeed. :) I did it , but had to check mysql tables.
Thanks!

So the main part is done.
Now need to config Drupal for this little content.

What I do is a site which let people get a free account and setup SMS chart or SMS live channel.
One easy number and many accounts.

Now I am fighting with Acees rules :). It let me setup minimum username length, coz I want to keep 4-letters and less usernames for special accounts.
The problem is, soecial usernames can't login after admin create the accounts for them because of access rules deny. I am trying to find out how to set access rules only for new registrations, not for already registered user. Huh...

But its a different story and different topic probably..

Thanks for your help man.

 
 

Drupal is a registered trademark of Dries Buytaert.