Paste Description for Drupal Twitter Post Form
Allows user roles with the 'twitter_post access' permission to send sms updates using Twitter.
Drupal Twitter Post Form
- <?php
- function twitter_post_perm() {
- } // function twitter_post_perm()
- function twitter_post_menu() {
- 'path' => 'twitterpost',
- 'title' => t('Send SMS update'),
- 'callback' => 'twitter_post_all',
- 'access' => user_access('access twitter_post content'),
- 'type' => MENU_NORMAL_ITEM,
- 'description' => t('Send messages to Twitter')
- );
- return $items;
- }
- function twitter_post_all() {
- return drupal_get_form('twitter_post_form');
- }
- function twitter_post_form() {
- '#type' => 'textfield',
- '#title' => t('text message'),
- '#size' => 60,
- '#maxlength' => 140,
- '#description' => t('text message to send out')
- );
- return $form;
- }
- function twitter_post_form_submit($form_id, $form_values) {
- $email = 'mytwitterusername';
- $password = 'mytwitterpassword';
- $url = "http://twitter.com/statuses/update.xml";
- $session = curl_init();
- curl_setopt ( $session, CURLOPT_URL, $url );
- curl_setopt ( $session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
- curl_setopt ( $session, CURLOPT_HEADER, false );
- curl_setopt ( $session, CURLOPT_USERPWD, $email . ":" . $password );
- curl_setopt ( $session, CURLOPT_RETURNTRANSFER, 1 );
- curl_setopt ( $session, CURLOPT_POST, 1);
- curl_setopt ( $session, CURLOPT_POSTFIELDS,"status=" . $status);
- $result = curl_exec ( $session );
- curl_close( $session );
- drupal_set_message(t('Message sent.'));
- }
- ?>