Comments (8)
I am not reproing on linux, see https://twitter.com/chronaldragon/status/821839149569228801
media_ids should not be included in the request if the member of the struct is null. I'm not familiar with D, is null there wrapped or anything?
I'd also recommend pulling down the latest revision from the repository, a few bugs were fixed last night that could affect the outcome of calls.
from twc.
Hmm, no, null is 0, I'll try pulling the latest and report back
from twc.
Updated to the latest and changed the code to this:
auto tweet = "looks like @chronaldragon's twc is working :) (this tweet sent from a #dlang script)";
auto test = twc_statuses_update_params.init;
test.MediaIds = cast(const(char)*)0;
twc_call_result x = twc_Statuses_Update(&twitter, twc_ToString(tweet.toStringz),
test);
writefln("%s", x.ErrorStr.Ptr[0..x.ErrorStr.Size]);
same response.
These are my bindings:
extern(C) {
struct CURL;
struct twc_strbuf {
size_t Size;
char* Ptr; }
struct twc_buffer {
size_t Size;
void* Ptr; }
struct twc_string {
size_t Size;
const(char)* Ptr; }
struct twc_oauth_keys {
const(char)* ConsumerKey;
const(char)* ConsumerSecret;
const(char)* TokenKey;
const(char)* TokenSecret; }
alias twc_malloc_func = void* function(size_t);
alias twc_free_func = void function(void*);
struct twc_state {
twc_malloc_func MemAllocFunc;
twc_free_func MemFreeFunc;
CURL* cURL;
twc_strbuf cURL_Error;
twc_buffer cURL_Data;
twc_buffer cURL_HeaderBuf;
twc_oauth_keys Keys; }
alias twc_error = int;
struct twc_call_result {
twc_error Error;
union {
twc_buffer Data;
twc_string ErrorStr; } }
alias twc_status_id = ulong;
alias twc_place_id = ulong;
pragma(mangle, "bool$") struct bool_ {
bool Exists;
bool Value; }
pragma(mangle, "twc_string$") struct twc_string_ {
bool Exists;
bool Value; }
pragma(mangle, "twc_status_id$") struct twc_status_id_ {
bool Exists;
twc_status_id Value; }
pragma(mangle, "twc_place_id$") struct twc_place_id_ {
bool Exists;
twc_place_id Value; }
struct twc_account_verifycredentials_params {
bool_ IncludeEntities;
bool_ SkipStatus;
bool_ IncludeEmail; }
struct twc_statuses_update_params {
twc_status_id_ InReplyToStatusId;
bool_ PossiblySensitive;
twc_string_ Lat;
twc_string_ Long;
twc_place_id_ PlaceId;
bool_ DisplayCoordinates;
bool_ TrimUser;
const(char)* MediaIds; }
void twc_Init(twc_state*, twc_oauth_keys);
twc_string twc_ToString(const(char)*);
twc_call_result twc_Account_VerifyCredentials(twc_state*, twc_account_verifycredentials_params);
twc_call_result twc_Statuses_Update(twc_state*, twc_string, twc_statuses_update_params);
}
I'm going to try writing a test in C and will see if the same thing happens
from twc.
Not sure how to compile this test in C:
#include <stdio.h>
#include "twitter.h"
#include "twitter_api.h"
//keys/secrets redacted
int main(int argc, char *argv[])
{
twc_oauth_keys keys = { CONSUMER_KEY, CONSUMER_SECRET, TOKEN_KEY, TOKEN_SECRET };
twc_state twitter;
twc_Init(&twitter, keys);
const char* tweet = "looks like @chronaldragon's twc is working from C";
twc_statuses_update_params test = {0};
twc_call_result x = twc_Statuses_Update(&twitter, twc_ToString(tweet),
test);
printf("%.*s\n", x->ErrorStr.Size, x->ErrorStr.Ptr);
return 0;
}
I get a big wall of errors if I include twitter_api.h and if I just include twitter.h I am missing twc_statuses_update_params
from twc.
I have not used D, but this seems suspect:
pragma(mangle, "twc_string$") struct twc_string_ {
bool Exists;
bool Value; }
Shouldn't Value be a twc_string?
from twc.
@miotatsu you should only need to include "twitter.h". If that struct name is missing you may need to redownload twitter_api.h/.c or re-run the code generator, since there was a buffer overflow problem causing the wrong names to be created sometimes, and I had pushed versions of the _api.h/.c files with that problem to the repo without noticing. The versions in there now have this fixed.
I'm not certain that I don't also have another bug which exists only on some platforms regarding the name generation, so if the versions that the code generator is building for you still have problems, please post an issue about it with compiler/platform so I can trace down the issue.
from twc.
Amendment to the earlier statements:
- Codegen problem is still reproing on Windows
- The files in the include/ folder haven't been getting updated, so that's probably why you still can't use the proper name for the statuses/update param struct (temp fix until I get another push out: use the ones from code/. I need to change the build process so that I only keep around one copy of these)
from twc.
@baines hit the nail on the head, that binding was incorrect causing the size of my struct to mismatch the actual. Changing from bool to twc_string fixed the problem! https://twitter.com/miotatsu/status/821932817663856640
Not going to bother getting the C test working as we found the problem
from twc.
Related Issues (9)
- off-by-one tests with ArgCount HOT 1
- no fclose in ReadFileAndNullTerminate HOT 1
- Should #include <alloca.h> in addition to #include <malloc.h> HOT 1
- C89 Compatibility HOT 1
- alloca.h is not standard HOT 5
- Buffer overflow codegen.c:253 HOT 1
- cp is not part of windows in build.bat HOT 3
- codegen creates incorrect parameter struct names in twitter_api.h HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twc.