I'm trying to publish a photo to a page using the following:
FacebookClient client = new DefaultFacebookClient(destinationAccessToken);
BinaryAttachment attachment = BinaryAttachment.with(imageName, imageInputStream);
Photo photoResponse = client.publish("/me/photos", Photo.class, attachment);
I'm getting the following response:
{
"error": {
"message":"An unexpected error has occurred. Please retry your request later.",
"type":"OAuthException",
"code":2
}
}
When I use the same code to publish to a user wall it works fine.
I've also tried posting to "/{page id}/photos" with the same result.
The destination access token has the manage_pages, photo_upload, publish_actions, and publish_stream permissions amongst others.
What am I doing wrong here?
UPDATE:
If I publish to a predetermined album using "/{album id}/photos" then it works. Quoting this Facebook developer blog post:
https://graph.facebook.com/USER_ID/photos - The photo will be
published to an album created for your app. We automatically create an
album for your app if it does not already exist. All photos uploaded
this way will then be added to this same album.
So is this behavior broken for pages? Or am I misunderstanding something here?
UPDATE 2:
I found a bug report for this issue, so I'm posting that as an answer.
UPDATE 3:
The bug seems to have been resolved.
I found the Facebook bug report corresponding to this behavior:
http://developers.facebook.com/bugs/355536551171535
So it would seem I'm not doing anything wrong. I guess the temporary workaround would be to check for a predetermined album and create it if necessary, then publish to it. (Note that the user_photos permission is not needed for this workaround, since albums/photos on pages are always public).
Related
I have been stuck for about the past 6 hours at this point I'm thinking the only reasonable explanations are that this is a AWS SDK bug or the error message is wrong.
I am using SESv2 class from the AWS SDK in a JAVA SpringBoot app and attempting to manage various details of my SES (Simple Email Service) account.
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sesv2.SesV2Client;
import software.amazon.awssdk.services.sesv2.model.*;
I have created an IAM user, created security credentials, set them up using multiple different methods as described here guid to credentials environment I've given full access to SES to this IAM role user. I then wrote some code and I was able to do all of the following,
Create a contact list
Delete a contact list
Create contact
Create a Topic in a contact list
Send an email
However, for some unknown reason when I go to test a function I wrote to get a list of contacts so I can test sending an email to multiple contacts I get the following 403 error message,
The request signature we calculated does not match the signature you
provided. Check your AWS Secret Access Key and signing method. Consult
the service documentation for details.
I've verified the credentials are correct. I have created a new set of credentials and made the old set inactive. No dice, all the functions listed above still work however the listContacts in the SesV2Client class still fails with the same error. As you can see below I even bypassed the env variables and just hardcoded the key and secret to pull out all the stops, still fails. In the function that fails, I've gone over and over the values im passing in they are valid and exist 100% because as I said I can make the other calls in the list above to verify the topics and contact list exists.
private List<Contact> listContactsForSiteUpdatesMailingList() {
try (SesV2Client client = SesV2Client.builder()
.region(Region.US_EAST_1)
.credentialsProvider(StaticCredentialsProvider.create(awsCreds))
.build()){
TopicFilter topicFilter = TopicFilter.builder().topicName(TOPIC_SITE_UPDATES).useDefaultIfPreferenceUnavailable(true).build();
ListContactsFilter listContactsFilter = ListContactsFilter.builder().topicFilter(topicFilter).filteredStatus(SubscriptionStatus.OPT_IN).build();
ListContactsRequest listContactsRequest = ListContactsRequest.builder()
.contactListName(CONTACT_LIST).filter(listContactsFilter).build();
ListContactsResponse listContactsResponse = client.listContacts(listContactsRequest);
return listContactsResponse.contacts();
} catch (Exception ex) {
System.out.println("The email was not sent. Error message: "
+ ex.getMessage());
return null;
}
}
Whats going on here and how can I get to the bottom of this error?
EDIT:
Looking at AWS Console Users>Access Management and then looking at the user a created I can even verify that there was "programmatic access"
An example of accessing a ContactList with no issues
EDIT 2: My SES account is currently sandboxed. I just wanted to mention the question is this possibly happening because of that? Grasping at straws here.
I was able to reproduce your issue. I created a list and added a contact. Both worked. However, when i executed listContacts, I got this error:
This looks like a bug. To address this, open a Github issue on the SDK Java Github here:
https://github.com/aws/aws-sdk-java
This is confirmed as a bug in the AWS SDK. To get around this you can use the async client like so
SesV2AsyncClient client = SesV2AsyncClient.builder()
.region(Region.US_EAST_1)
.build())
TopicFilter topicFilter = TopicFilter.builder().topicName(TOPIC_SITE_UPDATES).useDefaultIfPreferenceUnavailable(true).build();
ListContactsFilter listContactsFilter = ListContactsFilter.builder().topicFilter(topicFilter).filteredStatus(SubscriptionStatus.OPT_IN).build();
ListContactsRequest listContactsRequest = ListContactsRequest.builder()
.contactListName(CONTACT_LIST).filter(listContactsFilter).build();
CompletableFuture<ListContactsResponse> listContactsResponseCompletableFuture = client.listContacts(listContactsRequest);
ListContactsResponse listContactsResponse = listContactsResponseCompletableFuture.get();
I have tried to use WalletTemplate sub-project inside bitcoinJ lib. I have tried p2pkh sends and they work fine. But then I tried to make P2WPKH payment but it failed with the following error message
org.bitcoinj.core.RejectedTransactionException: Reject: tx
539c7f25b14b20dfad1ad66923fa59bf7531cd1ebda967e8346793fa2464f5dc for
reason 'non-mandatory-script-verify-flag (Signature must be zero for
failed CHECK(MULTI)SIG operation)' (64)
This behavior doesn't exist before commit. So I'm not sure how to handle the changes introduced since this change.
I have also create github issue to get more information but I haven't got any response yet. I have tried code outside of bitcoinj's walletTemplate in another project as follows:
NetworkParameters params = TestNet3Params.get();
Address destination = Address.fromString(params, strDest);
Coin value = Coin.parseCoin(strValue);
SendRequest request = SendRequest.to(destination, value);
SendResult result = wallet.sendCoins(request);
Any help would be appreciated. Thanks
Issue was solve on github via the latest commit 7c31dcb.
I have a Play (version 1.4) app currently hosted on Heroku that lets users create items for auction like eBay. The main process is the user fills out a form with information about the photo that is being uploaded. When the form is submitted the information is stored in a database. The photo however, I want to be stored using Amazon's S3 service. On success, the page that creates the auction item is directed to a page that shows the image with the information that was just uploaded.
I am probably more than half way there, because when my form submits, the image is successfully being sent to the bucket I created for it using S3. So that's good news. The bad news is, immediately upon submission, the app crashes, I get my "Oops!" error page, and when I check my database, none of the information was saved. The method responsible for creating the new auction item, doCreateItem(), the process I just described, where I am able to send the photo to AWS, but the app crashes not saving the data to the database, that method, looks like this:
public static void doCreateItem(#Valid AuctionItem item){
if (validation.hasErrors()){
params.flash();
validation.keep();
createAuctionItem();
}
// item.photo = new S3Blob();
// item.photo.set(new FileInputStream(item.photo), MimeTypes.getContentType(item.photo.getName()));
item.createdBy = Authenticate.getLoggedInUser();
item.save();
show(item.id);
}
https://github.com/cmazzochi81/java-play-app/blob/master/app/controllers/Application.java
And the stack trace, looks like this:
In the stack trace when it refers to this error:
Execution exception (In /app/controllers/Application.java around line 43)
Line 43 in my code is the following line where the method is trying to save the data to the database:
item.save();
Now when I uncomment out the two lines in the doCreateMethod()
item.photo = new S3Blob();
item.photo.set(new FileInputStream(item.photo)
When I do that, I'm not even able to push my app to Heroku. The error in the console says the constructor FileInputStream(S3Blob), is undefined:
I am trying to do the exact same thing James Ward does in this article:
https://www.jamesward.com/2011/09/13/sending-play-framework-file-uploads-to-amazon-s3
The GitHub repo for my project can be found here:
https://github.com/cmazzochi81/java-play-app
Your assistance would be greatly appreciated. I have worked extremely hard on this project, and it is this close to being done.
Thank you in advance,
CM
I'm discovering the google-api-java-client (google+) for java and for me it isn't clear how to get the total view count for any g+ profile.
In detail, I can get those properties outa Person model:
...
Person.getAboutMe()
Person.getPlusOneCount()
Person.getCircledByCount()
...
and lot's more but none with
getViewCount()
or something. Does anybody have a clue?
circlecount.com is also able to get information about the view count, but how?
Thanks for any help.
Cheers.
This information isn't currently exposed in the API, there is an open feature request for it here:
https://code.google.com/p/google-plus-platform/issues/detail?id=798
Circlecount uses page scraping to get some of the information that isn't available via the APIs.
There is currently no way to see the View count of someones Google+ profile though the API. A feature request has been made feel free to add your name to it. "views" in people.get response the more people that request it the better the chance we will have of them adding it.
I am using Twitter4J 2.2.5 (latest, tried other versions). And can no longer get direct messages to work at all. The same code used to work a while ago. I assume Twitter changed something.
I'm using
Twitter.getDirectMessages()
and it gives the error below. No idea why, I can see the direct messages for the account if I login, but always get this error. The limit error makes no sense, as the account is no where near the limit.
Other API work, like followers/fried/status/etc.
403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (http://support.twitter.com/forums/10711/entries/15364).
Relevant discussions can be on the Internet at:
http://www.google.co.jp/search?q=00919618 or
http://www.google.co.jp/search?q=332bf6ca
TwitterException{exceptionCode=[00919618-332bf6ca], statusCode=403, retryAfter=0, rateLimitStatus=RateLimitStatusJSONImpl{remainingHits=107, hourlyLimit=350, resetTimeInSeconds=1328297, secondsUntilReset=1116, resetTime=Fri Feb 03 14:39:45 EST 2012}, version=2.2.2}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:189)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:93)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1721)
at twitter4j.TwitterImpl.getDirectMessages(TwitterImpl.java:874)
at org.pandora.sense.twitter.TwitterDirectMessaging.checkDirectMessages(TwitterDirectMessaging.java:44)
at org.pandora.sense.twitter.TwitterDirectMessaging.checkProfile(TwitterDirectMessaging.java:35)
at org.pandora.sense.twitter.Twitter$1.run(Twitter.java:100)
at java.lang.Thread.run(Thread.java:662)
Twitter has some time ago changed the rules for direct messages. An app must be especially authorized by the user to access the direct messages.
Did you make sure this is true for you? You may go to the twitter web site and check for the app.
To get the direct message you should try the below code.It works for me.
getDirectMessages(); gives list of direct messages. We need to put for loop to get text of each message.
List<DirectMessage> messages = twitter.getDirectMessages();
for (DirectMessage message : messages)
{
System.out.println(message.getText());
}
Let me know if you get any error.