so I've been building this project and the IPN worked perfectly for my Sandbox - but as soon as I changed the URL to live, I got this log message.
I tried using this as a solution but still receiving the error.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close', 'User-Agent: company-name'));
The Message response I get is
<HTML>
<HEAD>
<TITLE>Access Denied</TITLE>
</HEAD>
<BODY>
<H1>Access Denied</H1>
You don't have permission to access "https://www.paypal.com/cgi-bin/webscr" on this server.<P>
Reference #18.........
</BODY>
</HTML>
The IPN im using is this one :
https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php
Can anyone please help. Thanks
It seems that I made an mistake, instead of adding in the additional line :
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close', 'User-Agent: company-name'));
I had to acutally just add in :
, 'User-Agent: company-name'
in the line that already existed. It's working now.
Related
I am getting error in AMP Form
<form class="innler-left" method="post" action-xhr="//mydoma.com/ xxxx/xxx/xxx/send.php" target="_top">
On submit getting below error in console.
Response must contain the AMP-Access-Control-Allow-Source-Origin header
Form submission failed: Error:
Response must contain the AMP-Access-Control-Allow-Source-Origin header _reported_
Once user submit the form it goes it php file in where I put the following header
header('HTTP/1.1 200 OK');
header("access-control-allow-credentials:true");
header("AMP-Same-Origin: true");
header("Access-Control-Allow-Origin:".$_SERVER['HTTP_ORIGIN']);
header("amp-access-control-allow-source-origin: https://".$_SERVER['HTTP_HOST']);
header("Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin");
header("access-control-allow-headers:Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token");
header("access-control-allow-methods:POST, GET, OPTIONS");
header("Content-Type: application/json");
I got it working offline on local machine but once i upload files, it not working :(
tried https://github.com/ampproject/amphtml/blob/master/spec/amp-cors-requests.md
POST __amp_source_origin is not matching!
I was also facing the same issue to fix this, make sure your URL start with https. And try to replace the following line in your code :
header("Access-Control-Allow-Origin:".$_SERVER['HTTP_ORIGIN']);
with
header("Access-Control-Allow-Origin: ". str_replace('.', '-','https://www.example.com') .".cdn.ampproject.org");
Note : Replace https://www.example.com with your AMP website URL
Hope it helps.
We are sending about 1 lac email daily using sendgrid API.
But what happen is thousand of mail are undelievered to the recipient.
we want to get the list of these undelievered mail. How is that possible ?
Please suggest some idea or links. becouse I am lost and would really appreciate the assistance.
Thank you.
wow..! finally i made it...
curl code-
curl -X GET
https://sendgrid.com/api/bounces.get.json?api_user=undefined&api_key=XXXXXXXX
and here is my the php code
$ch =curl_init('https://sendgrid.com/api/bounces.get.jsonapi_user=10timeslocal&api_key=10timeslocal');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
Thanks a lot to everyone tried to solve this.
I'd start with reading the API docs for bounces, blocks, invalid emails, and spam reports.
You can also consume SendGrid's Event Webhook which will send you post requests with the information you are looking for.
have a table in the database, that must contains the log of all emails send to users. then later fetch status of these emails via sendgrid apis. then update their status as success, bounce, invalid.
then for next time don't send emails to that persons whose status in your list are bounce or invalid.
this way you can avoid sending emails to bounces or invalid users.
I am running this website www.miswag.net which is highly dependent on Facbeook. When I share my site on Facebook, I get a "403 Forbidden", here's Facebook's debugger output when I try to scrape my site: https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.miswag.net
Please help figure this out.. Thanks
Facebook's scraper doesn't need to read the full page, so they only request part of it by sending a Range header. However, your server seems to be responding incorrectly to that request and returning a 403 error code. You need to check your server and make sure it handles the range header correctly.
To see this in action, try this CURL command:
curl -H "Range: bytes=0-524287" http://www.miswag.net
This is the response I got:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /
on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
Compounding on #Waleed'sanswer, if you want to test right away, use Online CURL
fill in www.wiswag.net
ADD OPTION options, choosing --header (-H)
next to it "Range: bytes=0-524287"
CURL button
I've noticed that some facebook pages redirect. For example the NOFX band page (http://www.facebook.com/pages/NOFX/104336479603261 only two links allowed so that one isn't set to link) redirects to their official page ( https://www.facebook.com/pages/NOFX-Official-Page/180985116576?rf=104336479603261 ). I'm curious is if in the api we can tell that a page does this. https://graph.facebook.com/104336479603261 doesn't seem to show anything about the redirect but, perhaps there's another way to find it.
Edit:
Solutions that don't use the api are fine.
Edit2:
Solved here is the code I used if anyone is interested:
Code mostly copied from How can I determine if a URL redirects in PHP?.
function getURL($URL)
{
$ch = curl_init($URL);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3');
curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
return $code;
}
Only thing really worth noting is that I had to add user agent so I don't get sent to an unsupported browser page.
Edit: Solutions that don't use the api are fine.
Then just make an HTTP HEAD request for the page URL, and see if you get a 301 Moved Permanently status code with a Location header in response. (Actually checking the status code only should be enough, if you only want to find out if the page gets redirected; if you also want to know where it’s getting redirected to, then check the location header as well.)
file_get_contents not working with following url (failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request)
$token_url = "https://graph.facebook.com/oauth/access_token?client_id=235326466577139&redirect_uri=http%3A%2F%2Fapps.facebook.com%2Flikeablephotos%2F&client_secret=CLIENT_SECRET&code=AQDFZbjpAUda8c_gz4wDDuBOVrsn0dApz3s8UA--7hFQIi1wb70-tDE56xXcCtDq-hV5UWzR5YEw_ozuGT24FLfvh9KnqHZ3xdn46P_KxYCf3DHJQA3AAu2ICHBqTk1-6fHTsl6FbagKz83H6dn15kkbKksajA4KcVIoPse5JbuBLlh6V5L1ANe8fzR94iH_SMU";
$response = file_get_contents($token_url);
but if you copy and paste the above URL into the browser address bar it works just fine! and returns:
access_token=AAADWBzZAyUvMBAL2Th6CRtxh2Up5soTCK8N4HJcy0ZBhQgJPxtZArKbuITISMoGLDxNiyeNW4GUZCBvJPeBTH6mx4v83ueUIAAYQJA1WrAZDZD&expires=5112501
but his similar URL (for a different user) also works:
$token_url = "https://graph.facebook.com/oauth/access_token?client_id=235326466577139&redirect_uri=http%3A%2F%2Fapps.facebook.com%2Flikeablephotos%2F&client_secret=CLIENT_SECRET&code=AQC2kTEV96-1Cki2oYUhyzjH6yFe6AJRd1Q3G8fbUXW-IsLJUlactzSwCvGVBK6jh1tL-t7v6dOWJZzbkSYhk0n2z6BHQcpljWAdoXFGB5zLC4FgW8fmxT6hwdRIQOr2dZ95CD_q5yJuOUz_2DItUa3_FF9m2_TmFYGEbxPoiaF47YSTUuZp6g-8ffziJcKDAdo";
when using file_get_contents
Please help, thanks
As an alternative to file_get_contents have you considered using cURL. I use curl for alot of requests with great results and on fail it will not expose your client secret.
refer to http://php.net/manual/en/book.curl.php
this code snippet is a standard for all my apps to get application access token. Can be used for all api calls.
$app_access_token = GetCH();
function GetCH(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
if(substr($url,0,8)=='https://'){
// The following ensures SSL always works. A little detail:
// SSL does two things at once:
// 1. it encrypts communication
// 2. it ensures the target party is who it claims to be.
// In short, if the following code is allowed, CURL won't check if the
// certificate is known and valid, however, it still encrypts communication.
curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_ANY);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
}
$sendCH = curl_exec($ch);
curl_close($ch);
return $sendCH;
};
Finally found the answer, had the same issue..the problem is most likely because facebook's code that they give you has spaces in between the params. If you just copied and pasted from Facebook, you will get a HTTP/1.1 400 Bad Request error. Put all the params on one line and remove all spaces and this should fix it. Worked for me. I know this is an older post but if you are having this problem let me know if it works for you!
For debugging:
Take the actual string in $token_url and paste into a browser address field and see what happens.
You will get some back some json error code.
For me, it was the my token was expired. Starting fresh request worked fine.
same problem happened to me the problem was access token supplied with the URL was expired since access token have 1 hour validity ,so i created a new access token and it works again ,hope this info helps .