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
- Saturday, September 15th, 2007 at 8:38:01am MDT
- <?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.'));
- }
- ?>
Paste Details
Tags: drupal
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.