Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27
  1. #11
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    You could use basic HTTP auth or just authenticate using OAuth at home or something and store the tokens in a DB or whatever.

  2. #12
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    Quote Originally Posted by Trinity View Post
    I think I see a flaw in this method. Wouldn't using OAuth take users to the twitter.com/oauth/blabla first? So it wouldn't work, as twitter is filtered at his school.
    Smart haha. Working on that you probably couldn't even use basic auth then as if it's blocked I doubt you can cURL it.

  3. #13
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Smart haha. Working on that you probably couldn't even use basic auth then as if it's blocked I doubt you can cURL it.
    If you cURL it then the request will be made on the server so it couldn't be blocked.

  4. #14
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    If you cURL it then the request will be made on the server so it couldn't be blocked.
    Exactly my point.
    Back for a while.

  5. #15
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    Oh right fair enough. I just assumed, wrongly I may add, that it would be blocked.

  6. #16
    Join Date
    Oct 2006
    Location
    West Midlands
    Posts
    463
    Tokens
    2,175

    Latest Awards:

    Default

    I've made little progress from my last post but I found this code;

    PHP Code:
    <?php
    $twitter_username 
    'TWITTER USERNAME HERE';
    $twitter_password 'TWITTER PASSWORD HERE';
    $errno 0;
    $errstr '';
    $response '';
    function 
    httpRequest($host$path '/'$method 'GET') {
     global 
    $errno$errstr$response;
     global 
    $twitter_username$twitter_password;
     
    $header  "$method $path HTTP/1.1\r\n";
     
    $header .= "Host: $host\r\n";
     
    $header .= "Accept-Encoding: none\r\n";
     
    $header .= "Authorization: Basic " base64_encode("{$twitter_username}:{$twitter_password}") . "\r\n";
     
    $header .= "Connection: Close\r\n\r\n";
     
    $sock fsockopen($host80$errno$errstr30);
     if (!
    $sock) {
         die(
    "<p><strong>fsockopen() error:</strong><br />$errstr ($errno)</p>");
     } else {
         
    fwrite($sock$header);
         while (!
    feof($sock)) {
       
    $response .= fgets($sock128);
         }
         
    fclose($sock);
         
    $response trim(str_replace(array('<''>'), array('&lt;''&gt;'), $response));
         return 
    true;
     }
    }
    echo 
    "<p>Contacting Twitter...</p>\n";
    httpRequest('twitter.com''/statuses/update.xml?status=Testing+Testing+1+2+3!''POST');
    echo 
    "<p>Response:<br /><hr /><pre>$response</pre><hr /></p>\n";
    ?>
    I'm rubbish at explaining so sorry if any one gets confused.

    If I edit the last few lines, that is what gets posted on to twitter, as I'm sure some of you would already be able to tell. This file requires me to edit the message at the bottom and then 'visit' the URL in order to post it.

    For example, if I uploaded that above code to my localhost, I'd visit localhost/twitter.php and then this would appear;

    HTML Code:
    Contacting Twitter...
    
    Response:
    HTTP/1.1 200 OKDate: Tue, 21 Jul 2009 18:27:40 GMTServer: hiLast-Modified: Tue, 21 Jul 2009 18:27:40 GMTStatus: 200 OKETag: "b363d4347d43725ea5d1c3ee0c63f8c8"Pragma: no-cacheCache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0Content-Type: application/xml; charset=utf-8Content-Length: 1722Expires: Tue, 31 Mar 1981 05:00:00 GMTX-Revision: a5c6210d770d282e091e8cae25fc5450b30f7a54X-Transaction: 1248200860-4861-14321Set-Cookie: lang=en; path=/Set-Cookie: _twitter_sess=BAh7CToJdXNlcmkEQxQDAToTcGFzc3dvcmRfdG9rZW4iLTk0YzAwYTQ0MzAw%250AYmI2ZjFmODNkZDZjZWNkNDA0ZDhlMmI5MGZlODg6B2lkIiVjMWY1M2Y3ZTAy%250AZDJmODE2OTE5OWQzNDY4NTRkYmFhZSIKZmxhc2hJQzonQWN0aW9uQ29udHJv%250AbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA%253D%253D--4ba6076345ffc1e6d9435db1252b14c823e4e579; domain=.twitter.com; path=/Vary: Accept-EncodingConnection: close<?xml version="1.0" encoding="UTF-8"?><status>  <created_at>Tue Jul 21 18:21:25 +0000 2009</created_at>  <id>2762283224</id>  <text>Testing Testing 1 2 3!</text>  <source><a href="http://apiwiki.twitter.com/">API</a></source>  <truncated>false</truncated>  <in_reply_to_status_id></in_reply_to_status_id>  <in_reply_to_user_id></in_reply_to_user_id>  <favorited>false</favorited>  <in_reply_to_screen_name></in_reply_to_screen_name>  <user>    <id>16979011</id>    <name>Craig Jones</name>    <screen_name>CraiggJ</screen_name>    <location>Dudley</location>    <description></description>    <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/318417751/abstract_brushes_2_normal.jpg</profile_image_url>    <url></url>    <protected>false</protected>    <followers_count>109</followers_count>    <profile_background_color>642D8B</profile_background_color>    <profile_text_color>3D1957</profile_text_color>    <profile_link_color>FF0000</profile_link_color>    <profile_sidebar_fill_color>7AC3EE</profile_sidebar_fill_color>    <profile_sidebar_border_color>65B0DA</profile_sidebar_border_color>    <friends_count>116</friends_count>    <created_at>Sun Oct 26 11:02:10 +0000 2008</created_at>    <favourites_count>5</favourites_count>    <utc_offset>0</utc_offset>    <time_zone>London</time_zone>    <profile_background_image_url>http://static.twitter.com/images/themes/theme10/bg.gif</profile_background_image_url>    <profile_background_tile>true</profile_background_tile>    <statuses_count>341</statuses_count>    <notifications>false</notifications>    <verified>false</verified>    <following>false</following>  </user></status>
    Some of that looks promising, but I'm not sure how I would go about doing, what I'm trying to achieve, like using fields in order to post to that file so I wouldn't have to manually insert user details (username, password) and what I'd do next.

    Sorry if I've confused some of you.
    Always lurking around, never really post.

  7. #17
    Join Date
    Oct 2006
    Location
    West Midlands
    Posts
    463
    Tokens
    2,175

    Latest Awards:

    Default

    I'm not sure what the rules are for double posting so I waited 24 hours
    So yeah, I wasn't sure what to do with the XML, how I would convert it sort of thing.
    So whilst I was waiting for a reply or a idea to pop in to my head.

    I just changed the code so I don't have to manually put the Twitter Name and Password in so I guess it's a type of login.

    I read that the curl could be used but I'm not sure how that works because on websites I've seen it posted like;
    HTML Code:
    curl --basic --user username:password --data status="Having fun with cURL" http://twitter.com/statuses/update.xml
    It's all very confusing lol, but I think I'm learning slowly...
    Always lurking around, never really post.

  8. #18
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    Just post the username, password and message to variables via a form and then use those variables to replace message, username and password things in the php.

  9. #19
    Join Date
    Oct 2006
    Location
    West Midlands
    Posts
    463
    Tokens
    2,175

    Latest Awards:

    Default

    PHP Code:
    <?php
    $twitter_username
    =$_POST['login'];
    $twitter_password=$_POST['passwd'];
    $status=$_POST['status'];
    $errno 0;
    $errstr '';
    $response '';
    function 
    httpRequest($host$path '/'$method 'GET') {
     global 
    $errno$errstr$response;
     global 
    $twitter_username$twitter_password;
     
    $header  "$method $path HTTP/1.1\r\n";
     
    $header .= "Host: $host\r\n";
     
    $header .= "Accept-Encoding: none\r\n";
     
    $header .= "Authorization: Basic " base64_encode("{$twitter_username}:{$twitter_password}") . "\r\n";
     
    $header .= "Connection: Close\r\n\r\n";
     
    $sock fsockopen($host80$errno$errstr30);
     if (!
    $sock) {
         die(
    "<p><strong>fsockopen() error:</strong><br />$errstr ($errno)</p>");
     } else {
         
    fwrite($sock$header);
         while (!
    feof($sock)) {
       
    $response .= fgets($sock128);
         }
         
    fclose($sock);
         
    $response trim(str_replace(array('<''>'), array('&lt;''&gt;'), $response));
         return 
    true;
     }
    }
    echo 
    "<p>Contacting Twitter...</p>\n";
    httpRequest('twitter.com''/statuses/update.xml?status=Test+again!''POST');
    httpRequest('twitter.com''/statuses/public_timeline.xml''GET');
    httpRequest('twitter.com''/statuses/friends.xml''GET');
    echo 
    "<p>Response:<br /><hr /><pre>$response</pre><hr /></p>\n";
    ?>
    That's what I have at the moment.
    I tried editing the /statuses/update.xml?status= bit so it will display what was posted on the field and what's displayed at the top of the code. How would I convert the XML into something readable? Unless you don't lol.
    Always lurking around, never really post.

  10. #20
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Nli. View Post

    I read that the curl could be used but I'm not sure how that works because on websites I've seen it posted like;
    HTML Code:
    curl --basic --user username:password --data status="Having fun with cURL" http://twitter.com/statuses/update.xml
    It's all very confusing lol, but I think I'm learning slowly...
    http://uk.php.net/curl
    Back for a while.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •