Facebook API error : Message: (#324) Missing or invalid image file - facebook-graph-api

I am getting an error while uploading an image to Facebook.
Both image and image path are proper but somehow it is not uploaded to Facebook when I am making a POST request to {pageid}/photos API call.
Here is my code.
$photoURL = 'https://www.example.com/images/img.png';
$uploadPhoto = $fb->post('/'.$pageId.'/photos', ['published' => 'false', 'url' => $photoURL]);
And it is giving following error.
Message: (#324) Missing or invalid image file
Please help me.
Thanks.

If you are trying to post from your localhost or virtualhost then error occurs because facebook can not find the url that you are providing.
Try this way:
search image from internet and pass its address to facebook SDK. I will post successfullty.
I was trying to send image from my virtualhost http:app.local.com/image-address and it gave same error. Then I picked an image form internet and passed then it was posted successfully.
Hope it solves your issue

For me it was the SSl certificate. It was on the server and valid over https, however I had an incorrect intermediate certificate on there. I saw the error when I checked the domain
https://cryptoreport.geotrust.com/checker/views/certCheck.jsp
Thanks
Grant

Related

django-rest-framework-social-oauth2: error 400 - redirect_uri_mismatch

I've been trying to add google login to my django app following this tutorial:
https://github.com/RealmTeam/django-rest-framework-social-oauth2
By following exactly the instructions, everything works fine in local.
However, when I try to replicate the same on the server, I get the following error on the redirect page of the login:
Error 400: redirect_uri_mismatch
redirect_uri: http://localhost:8000/auth/complete/google-oauth2/
What is strange to me is, in my google developer console, I have set up the correct redirect url in my app, as follows:
https://mydjangoapp.com/auth/complete/google-oauth2/
And I have also put 'mydjangoapp.com' under 'Authorised JavaScript origins'.
So my question is, why google keeps telling me that the redirect url is
http://localhost:8000/auth/complete/google-oauth2/
which is not the one I have set up in the console? Perhaps there is something obvious that I'm missing here. Thank you!
Why google keeps telling me that the redirect url is
Because your application is sending its in your code the app is running on http://localhost:8000 and if you are using a client library its probably adding the rest automatically.
http://localhost:8000/auth/complete/google-oauth2/
The redirect uri must exactly match what you are sending from your application.
You need to add
http://localhost:8000/auth/complete/google-oauth2/
Javascript origin is only needed if your code is using javascript.
This video will show you how to fix the error. Google OAuth2: How the fix redirect_uri_mismatch error. Part 2 server sided web applications.
If you want your code to send https://mydjangoapp.com then your going to have to be running it from https://mydjangoapp.com probably and you may need to figure out how to configure it so that it is running from the correct host.

Cloudfront 403 bypass

to give some context I am for the first time trying to participate in a BugBounty program and I found out which cloudfront URL is serving content to a website and the content being served is in json format.
Each time I try to access the information through the url of the website I get the next message:
{"error":"You need to sign in or sign up before continuing."}
If I try to access the Cloudfront url(xxxxxxx.cloudfront.net) I get:
403 ERROR
The request could not be satisfied.
Bad request. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
Generated by cloudfront (CloudFront) and a request id
I would like to know if somebody know a good article that explains how to bypass those 403 or 401 messages and obtain the JSON output
Thank you very much for all the information provided in advance.

Integrating Google Apis with Rails (Missing token endpoint URI Error)

I want to use google apis in my app.
I successful get my access token but I am getting error :-
"Missing token endpoint URI."
My code is
def calender
client = Signet::OAuth2::Client.new(access_token: session[:access_token])
drive = Google::Apis::DriveV3::DriveService.new
drive.authorization = client
files = drive.list_files
end
when I printed my client variable, it showed my these details
#<Google::Apis::DriveV3::DriveService:0x0000010cc287f8
#root_url="https://www.googleapis.com/",
#base_path="drive/v3/",
#upload_path="upload/drive/v3/",
#batch_path="batch",
#client_options=#<struct Google::Apis::ClientOptions application_name="unknown", application_version="0.0.0", proxy_url=nil, use_net_http=false>,
#request_options=#<struct Google::Apis::RequestOptions
authorization=#<Signet::OAuth2::Client:0x0000010cc288c0
#authorization_uri=nil,
#token_credential_uri=nil,
#client_id=nil,
#client_secret=nil,
#code=nil,
#expires_at=nil,
#expires_in=nil,
#issued_at=nil,
#issuer=nil,
#password=nil,
#principal=nil,
#redirect_uri=nil,
#scope=nil,
#state=nil,
#username=nil,
#expiry=60,
#extension_parameters={},
#additional_parameters={},
#access_token="ya29.CjAbA8B7CFyhBLhFuEtP6kmCmuvJESwClkchiPpydjAqBOvDuvDERVCSVrYSSWLZvZc">, retries=0,
header=nil,
timeout_sec=nil,
open_timeout_sec=20>
I have spent two days to resolve this and explored whole internet but my issue is not resolved. My issue is related to already reported issue :-
Missing token endpoint URI while using a valid access_token
But solution provided in it is also not working for me. There is no attribute of "authentication" that I can use to assign my token.
I would greatly appreciate if someone help me with this.

RestFB - Picture URL is not properly formatted

I'm trying to publish a post on my facebook page using RestFB.
My code is as follows:
FacebookType publishResponse = facebookClient.publish(pageId + "/feed", FacebookType.class,
Parameter.with("message", message),
Parameter.with("picture", picture),
Parameter.with("link", link),
Parameter.with("description", description));
And my parameters have the following values:
message: Test+test+test
picture: https%3A%2F%2Fcom-smallteaser-local-photo.s3.amazonaws.com%2Fskydivemag%25232fdefcfa-c7b2-4c0d-8504-9942ccd9a4b0%2523648%25230%25232592%25232592%2523292%2523292
link: http%3A%2F%2Flocalhost%3A9000%2Farticle%2F20130503-test-test-test
description: This+is+just+a+test
I am getting the exception:
FacebookOAuthException: Received Facebook error response of type OAuthException: (#100) picture URL is not properly formatted]
I read here that i can add a picture with just providing an URL and it specifically says that it is meant for 'App developers who host their images on Amazon S3 or a similar service'.
Any idea what i'm doing wrong?
I think it’s not actually the “formatting” of the picture URL, but the content it returns:
https://com-smallteaser-local-photo.s3.amazonaws.com/skydivemag%232fdefcfa-c7b2-4c0d-8504-9942ccd9a4b0%23648%230%232592%232592%23292%23292
is delivered with a Content-Type: application/octet-stream response header (as you can see here) – and that might make Facebooks scraper think that this is not really an image resource.
So you will have to figure out how configure your hosting space to deliver these images with a correct Content-Type, for example img/jpeg or img/png.
I got this problem, but only on older Android devices, not on a desktop. I could see in the server logs that there was a difference:
When accessing the URL on a desktop, Facebook does request the picture URL.
When accessing the URL on an older Android device, Facebook does not request the picture URL.
It turned out that I was using window.location.origin in constructing the absolute URL, which according to http://www.hyperink.com/blog/?p=18 only works on Webkit. It was solved by replacing, as the post suggests,
window.location.origin
by
window.location.protocol + “//” + window.location.hostname

how to debug facebook app/django setup (url is not valid...)

I'm trying to set up a facebook app using django by following this tutorial: http://www.rkblog.rk.edu.pl/w/p/example-facebook-application-django/ . I get to the point where I start my development server at (manage.py runserver 0.0.0.0:80)
then it says: Now under http://apps.facebook.com/NAME/ you should see a basic Facebook app comming from your server:
I, however, get an error message:
The URL http://my.ip/my_app_name/ is not valid.
I think I've set things up properly:
Canvas Page URL:
http://apps.facebook.com/my_app_name/
Canvas Callback URL
http://my.ip/my_app_name/
Question: how do I go about finding out what's wrong?
Thanks in advance!
Martin
update: when i visit http://my.ip/myappname/, it redirects to http://apps.facebook.com/my_app_name/?auth_token=eac7bf38fb5e591c55ddc458d16dc9b7
where i get the 'url not valid' message... However, when I paste the url with auth_token in it, django serves the requested page as expected... why is facebook saying the url is not valid if in fact it is...?
Is your router set up to forward requests on port 80 to your development machine? If not, you will get an error, as the way Facebook apps work is that Facebook's servers contact your server, get the content, then parse it and re-serve it back to the client.
I actually find with Facebook apps that the easiest thing to do is what you describe in your last sentence - get the auth_token URL, then paste it locally and work from there.