I have a problem .
I want to delete photos on facebook page , photos are sending via php sdk.
Im try all but not work..
$Curl_Session = curl_init('https://graph.facebook.com/[photoid]');
curl_setopt ($Curl_Session, CURLOPT_POST, 1);
curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "method=DELETE&access_token=$token");
curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($Curl_Session, CURLOPT_RETURNTRANSFER, 1);
echo $a8=curl_exec ($Curl_Session);
curl_close ($Curl_Session);
Dont work..
$url = 'https://graph.facebook.com/'.$id.'?method=DELETE&access_token='.$token;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
echo $data = curl_exec($ch);
This code is dont work
$sonuc=file_get_contents("https://graph.facebook.com/".$id."?method=DELETE\&access_token=".$token);
Please Help..
Facebook allowed deleting photos if sending via php sdk.
But all codes not work ..
First off, the photo you're trying to delete must have been uploaded by the app that's trying to delete it. This is mentioned in the Facebook Documentation: A photo can only be removed by the same app that published it.
You'll need a valid Page Access Token to delete the photo too. You can get this my adding the manage_pages permission and calling /me/accounts to get the list of access tokens, finding the one for the correct page).
Finally, calling: https://graph.facebook.com/{PHOTO_ID}?access_token={PAGE_ACCESS_TOKEN}&method=DELETE will delete the photo if the app has permission, otherwise you'll receive a error like:
{
"error": {
"message": "(#200) Permissions error",
"type": "OAuthException",
"code": 200
}
}
Related
I just want to get the authorization code to obtain the access token to make API requests, I did the step manaully through the pasting the link in the browser and it works.
but through Curl PHP doesn't work I get empty string of size 1400 char.
this's the sample on Quickbooks API doc
curl -X POST 'https://appcenter.intuit.com/connect/oauth2?
client_id=Q3ylJatCvnkYqVKLmkxxxxxxxxxxxxxxxkYB36b5mws7HkKUEv9aI&response_type=code&
scope=com.intuit.quickbooks.accounting&
redirect_uri=https://www.mydemoapp.com/oauth-redirect&
state=security_token%3D138r5719ru3e1%26url%3Dhttps://www.mydemoapp.com/oauth-redirect'
Quickbooks API Auth code ref
I Turned to Curl PHP with replacing my credentials, when I visit the link I get the auth code and I could obtian the access token but can't do it in the back-end
the dir of the page that I want to get the auth code in is https://roifelawgroup.com/clientform/login/info_submit.php
but the redirect link just : https://roifelawgroup.com/ with login creds is this could be the problem?
However I tried with the same page redirect link didn't work
function authcode(){
$url = "https://appcenter.intuit.com/connect/oauth2?client_id=ABfQBA8VYPPUETO5isi2v8p39lQwEsw1ozL7NhZxxxxxx&response_type=code&scope=com.intuit.quickbooks.payment&redirect_uri=https://roifelawgroup.com&state=security_token%3D138r5719ru3e1%26url%3Dhttps://roifelawgroup.com";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // if removed this line I get 301 permanently moved
$headers = array(
"Content-Length: 0",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);
}
How to get the Facebook hashtag feeds using the Facebook Graph API ? I want to get all the posts of a particular #HashTag.
I tried the below code:
<?php
$keyword = '#TagName';
$graph_url = "https://graph.facebook.com/search?type=post&access_token=xxx&q=$keyword";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $graph_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
var_dump($result);
?>
But it returns an error :
string(82) "{" error":{"message":"No node specified","type":"GraphMethodException","code":100}}"
permission granted : read_stream
any solution for this? thank you
You cannot retrieve the hashtag feed using the API, unless you are using Facebook Trending API (which you will not get access)
https://developers.facebook.com/docs/graph-api/reference/v2.3/hashtag
I have a Facebook app, where I want to delete some pictures. I have the pictureid and access_token, and have tried every methods I have found on this site, but I get errors every time.
How can this be deleted with CURL? I've started with this:
$ch = curl_init();
$url = 'https://graph.facebook.com/'.$uid.'/photos?access_token='.$access_token;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
echo $data = curl_exec($ch);
Applications can now delete Photos - created by that application.
I tried it with a photo uploaded to a page and deleted it with its id via the Graph API Explorer
The curl url would be:
https://graph.facebook.com/'.$imageId.'?method=DELETE&access_token='.$token
Facebook does not permit applications to delete photos at all.
I have Facebook app in my site. When we integrate Facebook, it will leads to facebook login page everytime,but i want to login facebook from mysite. I will give separate login form for facebook, when we enter the facebook crendential in mysite login, it will login to facebook without asking facebook login page. Is it possible to do? I try the following curl function to do but not succeed
<?php
$EMAIL = "fb_user_email";
$PASSWORD = "password";
function cURL($url, $header=NULL, $cookie=NULL, $p=NULL)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_NOBODY, $header);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if ($p) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
}
$result = curl_exec($ch);
if ($result) {
return $result;
}
else {
return curl_error($ch);
}
curl_close($ch);
}
$a = cURL("https://login.facebook.com/login.php?login_attempt=1",true,null,"email=$EMAIL&pass=$PASSWORD");
preg_match('%Set-Cookie: ([^;]+);%',$a,$b);
$c = cURL("https://login.facebook.com/login.php?login_attempt=1",true,$b[1],"email=$EMAIL&pass=$PASSWORD");
preg_match_all('%Set-Cookie: ([^;]+);%',$c,$d);
for($i=0;$i<count($d[0]);$i++)
$cookie.=$d[1][$i].";";
echo cURL("http://graph.facebook.com/oauth/authorize?client_id=APP_IDredirect_uri=APP_REDIRECT_URL&display=touch&scope=publish_stream, user_checkins, publish_checkins, offline_access",null,$cookie,null);
?>
Please help me to do. This is my task
Thanks in advance
No, it isn't possible.
A glance at the Facebook sites shows something that appears to be CSRF protection in the source code for the login form. So you can't have a form on your own site pointing at theirs.
Using cURL in the way you appear to be trying to wouldn't work either, because you wouldn't be able to set the cookies that Facebook sends on the user's browser as you couldn't associate them with a different domain.
In either case, expecting people to enter their login credentials for another site on yours is, at best training them to be unsafe with their passwords. (Not that facebook is any better with their constant attempts to get my email password via "friend finder").
Facebook does not allow direct login from third party application. One has to use facebook website for authentication.
It gives added security as the user credentials are not shared with third party applications but only facebook.
I set up a Wufoo form with admin only portions that will only show up if I am logged in. I read through the Wufoo API documentation and I can get the authenication to work, but when I try to access the form after I authenticate, it says I need to authenticate. This is what I have so far (subdomain, api key & form id changed)
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$curl1 = curl_init('http://fishbowl.wufoo.com/api/v3/users.xml');
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl1, CURLOPT_USERPWD, 'AOI6-LFKL-VM1Q-IEX9:footastic');
curl_setopt($curl1, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl1, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl1, CURLOPT_USERAGENT, 'Wufoo Sample Code');
$response = curl_exec($curl1);
$resultStatus = curl_getinfo($curl1);
if($resultStatus['http_code'] == 200) {
echo 'success!<br>';
} else {
echo 'Call Failed '.print_r($resultStatus);
}
$curl2 = curl_init("http://fishbowl.wufoo.com/api/v3/forms/w7x1p5/entries.json");
curl_setopt($curl2, CURLOPT_HEADER, 0);
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl2);
curl_close ($curl2);
echo $response;
curl_close($curl1);
?>
It doesn't matter if I close $curl1 before or after I call $curl2, I get the same message on my screen:
success!
You must authenticate to get
at the goodies.
and I know the api, subdomain and form id are all correct.
And one last bonus question... can I do all of this using Ajax instead? - the page I will be displaying the form on will already be limited to admin access, so exposing the API shouldn't matter.
Okay I did some digging around.
Here's the thing, you need to authenticate for every call you want to make to the API.
I noticed that in the URL that you used (http://fishbowl.wufoo.com/api/v3/users.xml) , you used http but the API requires you to use https. You will only get that You must authenticate to get at the goodies. message if you attempt to access through the normal HTTP protocol.
So for your second call, you need to re-authenticate again.
Your code should then look like:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$curl1 = curl_init('https://fishbowl.wufoo.com/api/v3/users.xml');
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl1, CURLOPT_USERPWD, 'AOI6-LFKL-VM1Q-IEX9:footastic');
curl_setopt($curl1, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl1, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl1, CURLOPT_USERAGENT, 'Wufoo Sample Code');
$response = curl_exec($curl1);
$resultStatus = curl_getinfo($curl1);
if($resultStatus['http_code'] == 200) {
echo 'success!<br>';
} else {
echo 'Call Failed '.print_r($resultStatus);
}
$curl2 = curl_init("https://fishbowl.wufoo.com/api/v3/forms/w7x1p5/entries.json");
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl2, CURLOPT_USERPWD, 'AOI6-LFKL-VM1Q-IEX9:footastic');
curl_setopt($curl2, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl2, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl2, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl2, CURLOPT_USERAGENT, 'Wufoo Sample Code');
$response = curl_exec($curl2);
curl_close ($curl2);
echo $response;
curl_close($curl2);
?>
Regarding your question about all these being done in AJAX, it's not possible at the moment because Wufoo does not support JSONP callbacks (which allow for cross domain AJAX requests). (If you don't know what I'm talking about read this other SO question) However, if you want to plug this functionality into AJAX, you can do an AJAX call to your PHP script on the local server. The PHP script will do something like the above, authenticating with Wufoo.