Facebook Hashtag feed PHP cURL - php

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

Related

YouTube v3 API call for search.list: proper curl setting

I am sending a call to the YouTube API using search.list (retrieve the first search result for a keyword) but I am getting nothing in return.
Here is my call:
$api_url = 'https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&type=video&key=MYKEY&&format=json&q=SEARCHTERMS;
Note: MYKEY is my API key I got from Google (currently active) and SEARCHTERMS is any word to search.
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response);
$value = json_decode(json_encode($data), true);
echo $value;
The URL works correctly (tested on browser) and I'm not getting any kind of error (console), but still this curl request isn't echoing any data from YouTube. Isn't it properly set?
P.s. My quota isn't exceeded.
SOLVED!
Watch out: youtube API doesn't read spaces in url (eg. in search terms), so you gotta streplace all of them with "+"

file_get_contents & curl returns empty string for google trends

i tried getting the contents of this url
http://www.google.com/trends/fetchComponent?q=ex%20machina&cid=TIMESERIES_GRAPH_0&export=3
with file_get_contents and curl but it returns nothing, however when i went directly to the link it shows the content so its not a problem with api limits etc.
It worked once, but not after subsequent calls
heres the curl method i used
function get_data($url) {
$ch = curl_init();
//$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
I had a similar problem with the Google Maps Geocoder API in combination with file_get_contents, you can find the solution here:
Google Maps Geocode API only works via browser
Try this url:
http://www.google.com/trends/fetchComponent?q=ex+machina&cid=TIMESERIES_GRAPH_0&export=3

How can I Delete Photo On facebook Pages via PHP SDK?

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
}
}

Delete pictures from Facebook using CURL

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.

Telegram Api - Creating an Authorization Key 404 error - PHP

I am trying to write a simple program in PHP to use telegram api, (not bot api, main messaging api). when i run my script, result is 404 error. Why?
<?php
$postfields = array();
$postfields['phone_number'] ='+1234567890';
$postfields['sms_type'] ='0';
$postfields['api_id'] ='12345';
$postfields['api_hash'] ='abcdefghijklmnopqrstuvwxyz';
$postfields['lang_code'] ='en';
$url = '149.154.167.40:443';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
echo $html=curl_exec($ch);
curl_close($ch);
?>
tanks a lot.

Categories