ioexception - Viewing Profile: Topics - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

ioexception

Member Since 20 Dec 2014
Offline Last Active Sep 03 2015 03:05 PM
-----

Topics I've Started

Using the onboard 3.3v output

06 July 2015 - 04:11 AM

Is there any special configuration that I should use to get the onboard 3.3v (or the 5v) output, I'm trying to power some leds but it doesn't work. I'm pretty sure the port works perfect because it outputs power when the board restarts but once my program is loaded the port does not work any more.

 

Thanks in advance.

 


POST request to Twitter with Netduino Plus 2

20 December 2014 - 06:25 PM

string oauth_nonce = Utility.RandomString(32);
        string oauth_timestamp = Utility.Timestamp.ToString();
        string oauth_signature = null;
        string encodedTweet = HttpUtility.UrlEncode(tweet);
        string signingKey = HttpUtility.UrlEncode(ConsumerSecret) + "&" + HttpUtility.UrlEncode(AccessTokenSecret);
        string requestLine = "POST https://api.twitter.com/1.1/statuses/update.json HTTP/1.1";
        string requestBody = "status=" + encodedTweet;

        string paramsString = "oauth_consumer_key=" + HttpUtility.UrlEncode(ConsumerKey) +
                                "&oauth_nonce=" + HttpUtility.UrlEncode(oauth_nonce) +
                                "&oauth_signature_method=" + HttpUtility.UrlEncode("HMAC-SHA1") +
                                "&oauth_timestamp=" + oauth_timestamp +
                                "&oauth_token=" + HttpUtility.UrlEncode(AccessToken) +
                                "&oauth_version=" + HttpUtility.UrlEncode("1.0") +
                                "&" + requestBody;

        string signatureBase = "POST&" + HttpUtility.UrlEncode("https://api.twitter.com/1.1/statuses/update.json") +
                                "&" + HttpUtility.UrlEncode(paramsString);

        byte[] signatureBytes = Sha.ComputeHMACSHA1(Encoding.UTF8.GetBytes(signingKey),
            Encoding.UTF8.GetBytes(signatureBase));
        oauth_signature = HttpUtility.ConvertToBase64String(signatureBytes);

        byte[] requestBodyBytes = Encoding.UTF8.GetBytes(requestBody);

        string otherHeaders = "Host: api.twitter.com" + CRLF +
                                "Connection: Close" + CRLF +
                                "Accept: */*" + CRLF +
                                "User-Agent: Tuitduino v0.1" + CRLF +
                                "Content-Type: application/x-www-form-urlencoded" + CRLF +
                                "Content-Length: " + requestBodyBytes.Length;

        string authorization = "Authorization: OAuth oauth_consumer_key=\"" + HttpUtility.UrlEncode(ConsumerKey) + "\", " +
                                "oauth_nonce=\"" + HttpUtility.UrlEncode(oauth_nonce) + "\", " +
                                "oauth_signature=\"" + HttpUtility.UrlEncode(oauth_signature) + "\", " +
                                "oauth_signature_method=\"HMAC-SHA1\", " +
                                "oauth_timestamp=\"" + oauth_timestamp + "\", " +
                                "oauth_token=\"" + HttpUtility.UrlEncode(AccessToken) + "\", " +
                                "oauth_version=\"1.0\"";

        string fullRequest = requestLine + CRLF + otherHeaders + CRLF + authorization + CRLF + CRLF + requestBody;
        byte[] requestBytes = Encoding.UTF8.GetBytes(fullRequest);

        using (var socket = Network.Connect())
        {
            socket.Send(requestBytes, requestBytes.Length, 0);
        }

Hi guys, I'm new to netduino and I'm trying to send a POSTrequest to update an status to Twitter API, at this moment I generate the request and send it using raw sockets but it always return 403 Authentication Required, but when I grab the same request and send it vía Fiddler everything goes OK. Can any of you tell me what is wrong? I'm thinking that it might has something to do with indicating the end of the body message.  Here is my code:


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.