I'm trying to update the status of a user and then immediately retweet it. I can't figure out how to get the ID of the status I just submitted though.
Any help would be greatly appreciated.
Are you doing a
twitter.updateStatus("Some String");
If so, this returns a Status, which has a getId() method
myStatus = twitter.updateStatus("Some String");
myId = myStatus.getId();
If not, please post your code.
Related
Long time reader, first time poster, please be gentle.
I've been working on a web app using Flask and SQLAlchemy that allows users to review and comment on MMA fights. I have a list of fights in a SQL table appropriately named "fights" and I'm trying to use dynamic routing to filter through the data. I have a list of all the fights on one route like so:
#app.route('/ufc251')
#login_required
def ufc251():
return render_template('ufc251.html', fights=Fight.query.all())
which helped me make a slick page with all the fights listed, and then made another route for info on individual fights like so:
#app.route('/fight/<int:id>')
#login_required
def fight(id):
id = Fight.query.filter_by(id=id).first_or_404()
return render_template('fight.html')
so far, so good. If I click on a fight from the main page i get sent to a url fightsite/fights/<fight_id>, which is perfect. The problem that I'm having is that I can't for the life of me figure out how to call the data from the row for a single fight. If i change my route to:
#app.route('/fight/<int:id>')
#login_required
def fight(id):
id = Fight.query.filter_by(id=id).first_or_404()
return render_template('fight.html', fight=Fight.query.filter_by(id=id).first())
I get the error
sqlalchemy.exc.ArgumentError: Object <Fight 1> is not legal as a SQL literal value
but if i give id a value (i.e. id=1) it will display the data from the first row in my fights table, so i feel like the problem is in the (id=id) part, but after hours of scouring the internet, I can't seem to find a solution.
Any help would be greatly appreciated. And yes, I've read the other StackOverflow article on this subject, however the answer doesn't seem to apply to this situation.
Thank you in advance!
I figured it out, however I decided I'd leave the question in case anybody else has this issue.
i changed:
#app.route('/fight/<int:id>')
#login_required
def fight(id):
id = Fight.query.filter_by(id=id).first_or_404()
return render_template('fight.html', fight=Fight.query.filter_by(id=id).first())
to:
#app.route('/fight/<int:id>')
#login_required
def fight(id):
id = Fight.query.filter_by(id=id).first_or_404()
return render_template('fight.html', fight=Fight.query.filter_by(id=id.id).first())
because initially it was passing the argument 'fight_1' instead of just '1'. I hope nobody else has to spend this long trying to solve the same problem!
The use of id to hold a Fight confuses things. Then there's the double query when one would suffice.
Consider changing
id = Fight.query.filter_by(id=id).first_or_404()
return render_template('fight.html', fight=Fight.query.filter_by(id=id).first())
to
fight = Fight.query.filter_by(id=id).first_or_404()
return render_template('fight.html', fight=fight)
I am trying to get the users' birthday via
$.getJSON("https:graph.facebook.com/me?fields=birthday&access_token="+accessToken, function(data) {
});
But unfortunately I have no idea on how to get the birthday itself because it gives me back this huge Object were I don't know how to handle it:
Could anyone please help me. I was looking at similar questions but unfortunately making the $.getJSON synchronous as suggested here is deprecated. The questions here and here did not really help either. Thanks in advance :)
To get the birthday in your code, you need navigate into Objects of your JSON data.
`$.getJSON("https://graph.facebook.com/me?fields=birthday&access_token="+accessToken, function(data) {
var birthday = data.birthday // This is your birthday
var id = data.id // This is your Fb ID
console.log('Hi! '+ id +'. Your birthday is '+ birthday)
});`
I have been using soapui opensource for a small period and not yet good at groovy script. Please help figuring out the following issue:
I get response from the previous test step. Lets say Response1 and need to parse it in order to get Id value from it. Then I need to add string DomainId before this id so that it looked smth like this:
DomainId_234565
and tranfer it to next request.
Could someone please explain how to do it with groovy? (I guess it is the best way to do it)
Thank you
Managed to resolve myself. Add property step response where I store response from previous step and also added property trasfer step to put response to the property. Then I add groovy script: def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def holder = groovyUtils.getXmlHolder("Properties#response") return "DomainId_ " + holder.getNodeValue("//*:Id") and it works, returns the correct value
I'm using Dropnet library to communicate with Dropbox.
After I accept the first time that my account allows my APP I save the token and secret forn next time I can process whatever I want without asking the user again.
But after I do this code:
Try
client.UserLogin = New UserLogin()
client.UserLogin.Token = dropboxAtoken
client.UserLogin.Secret = dropboxAsecret
Dim accountInfo As AccountInfo = client.AccountInfo()
' More of my code
Catch ex As DropNet.Exceptions.DropboxException
messagebox.show(ex.Message.ToString)
End Try
I receive this error:
{"error": "Parameter not found: oauth_token"}
Can anyone help please.
You should use the overload on the DropNetClient constructor that takes both API keys and User tokens that way it will get correctly wired up.
Or create the instance of the UserLogin first then set it on the client.
See the code for the setter of that parameter wires it up when setting it:
https://github.com/DropNet/DropNet/blob/master/DropNet/Client/Client.cs#L32
I'm trying to run a very quick update query to record that a user's email address is confirmed (setting the confirmed [bit] column in my users table to 1 after they click a link sent via email). Here's the action that should do it:
<cffunction name="confirmEmail">
<cfscript>
user = model("user").findOne(where="id=#params.userid# AND uuid='#params.uuid#'", returnAs="query");
if(user.recordCount) {
pageTitle = "E-mail Confirmation Success";
user.update(confirmed=1);
} else {
redirectTo(route="authenticationDenied", alert="Something was wrong with your confirmation string. Please contact site administrators.");
}
</cfscript>
</cffunction>
But when I submit the appropriate URL (I've dumped and can see the model call finds one valid record), I get the following error in Railo 3.3.x:
No matching Method/Function [update] for call with named arguments found
...highlighting the user.update(confirmed=1); line in my code. So what am I doing wrong? Previously I have always used save/update(params.user) or thereabouts for these queries, but that seems like overkill here; I just want to pass a 1-bit update.
Okay, my CTO who is new to CFML and Wheels figured this out in like 5 seconds. Hence the "C" I guess.
By returning the user model as a query instead of an object, I didn't have access to the update/save() methods. (Duh, MVC n00b.) The reason I was returning it as a query was simply that I've been doing that a fair bit in order to have easy manipulation of output, and in this case so that I can test for the existence of a record the way I always have (if recordCount). But this works...
<cffunction name="confirmEmail">
<cfscript>
user = model("user").findOne(where="id=#params.userid# AND uuid='#params.uuid#'");
if(isObject(user)) {
user.update(confirmed="1");
} else {
flashInsert(error="Something was wrong with your confirmation string. Please contact site administrators.");
redirectTo(route="authenticationDenied");
}
</cfscript>
</cffunction>