I'm trying to write a simple app for my website and struggling with 1 point.
A Facebook Page has;
$pageID = 'dorimedia';
What does a website have that is equal? I want to get the value to show how many times an external website has been 'liked'.
Nothing.
You could use the domain name, or domain name + path as in full route, but no short ID per se.
http://www.google.com could be the id
http://www.google.com/route could also be an id
If you need something shorter, and not necessarily readable by you, you could hash it or apply some encrypting algorithm to the full url to get a shorter id, try looking into the md5,sha1 or hash methods (assuming your using php)
UPDATE
If what you need is how many facebook like's a website has, there is an API for this directly from google that goes like this:
http://api.facebook.com/restserver.php?method=links.getStats&urls=www.google.com
Which results in an xml response that includes, comments, likes and other interesting information. Google for instance has the following response:
<links_getStats_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
<link_stat>
<url>www.google.com</url>
<normalized_url>http://www.google.com/</normalized_url>
<share_count>2095550</share_count>
<like_count>795778</like_count>
<comment_count>705595</comment_count>
<total_count>3596923</total_count>
<click_count>265614</click_count>
<comments_fbid>381702034999</comments_fbid>
<commentsbox_count>307</commentsbox_count>
</link_stat>
</links_getStats_response>
Then its a matter of extracting the information from that XML, easily enough like this:
$url = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".urlencode($source_url);
$xml = file_get_contents($url);
$xml = simplexml_load_string($xml);
$shares = $xml->link_stat->share_count;
$likes = $xml->link_stat->like_count;
$comments = $xml->link_stat->comment_count;
$total = $xml->link_stat->total_count;
$max = max($shares,$likes,$comments);
Click here for the Source
Related
I'm trying to get keyword ideas from AdWords API by page URL, but so far I'm only able to get keywords list by another keyword.
What I want to do is possible via web interface, but as for API, docs say that the only available value for ideaType property is KEYWORD.
Are there any alternatives for ideaType, maybe via creating a new campaign, or something else?
I'm using PHP.
I'm new to Google AdWords. Help appreciated!
In fact, I misunderstood the goal of ideaType property. This property is not the input search parameters type.
For getting keyword ideas by URL you can use RelatedToUrlSearchParameter class.
In my case code looks like following (the most relevant part):
$selector = new TargetingIdeaSelector();
$selector->requestType = 'IDEAS';
$selector->ideaType = 'KEYWORD';
$selector->requestedAttributeTypes = array('KEYWORD_TEXT', 'SEARCH_VOLUME', 'CATEGORY_PRODUCTS_AND_SERVICES');
$relatedToUrlSearchParameter = new RelatedToUrlSearchParameter();
$url = $_GET['url'];
$relatedToUrlSearchParameter->urls = array($url);
$selector->searchParameters[] = $relatedToUrlSearchParameter;
As recently as two days ago, the following code worked to get the search query from google:
$refer = parse_url($_SERVER['HTTP_REFERER']);
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
$query = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
if(strstr($host,'www.google.com'))
{
//do google stuff
$qstart = strpos($query, 'q=') +2;
$qend = strpos($query, '&', $qstart);
$qlength = $qend - $qstart;
$querystring = substr($query, $qstart, $qlength);
$querystring = str_replace('q=','',$querystring);
$keywords = explode('%20',$querystring);
$keywords = implode(' ', $keywords);
return $keywords;
}
However, now it does not. I tested it by using echo($query) and it appears that the way google processes referrer query requests has changed. Previously $query included
"q=term1%20term2%20term3%20...
Now, however, I am getting the following output when $query is echo'ed:
sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CCsQFjAB&url=http%3A%2F%2Fexample.com%2F&ei=vDA-UNnxHuOjyAHlloGYCA&usg=AFQjCNEvzNXHULR0OvoPMPSWxIlB9-fmpg&sig2=iPinsBaCFuhCLGFf0JHAsQ
Is there a way to get around this?
Sorry to say, but it's global Google politics change.
See web link
http://googlewebmastercentral.blogspot.ru/2012/03/upcoming-changes-in-googles-http.html
This means if user sign in Google account.
You can try it yourself: if your Google search url starts with https:// this means Google will hide some scratch parameters for the sake of privacy.
I too ran into the same issue this week. I'm not sure if this is still relevant to you, but what I found was that Google initiated SSL (Secure Sockets Layer) search for users who were signed in about a year ago, and it looks like SSL search may now be applied to all Google search queries. When I tested this, I was not signed in to Google and was using Firefox and still got the encrypted referring query.
This article has some helpful background and some ideas for working without specific search term data: http://searchenginewatch.com/article/2227114/5-Tips-for-Handling-Not-Provided-Data
// take the referer
$thereferer = strtolower($_SERVER['HTTP_REFERER']);
// see if it comes from google
if (strpos($thereferer,"google")) {
// delete all before q=
$a = substr($thereferer, strpos($thereferer,"q="));
// delete q=
$a = substr($a,2);
// delete all FROM the next & onwards
if (strpos($a,"&")) {
$a = substr($a, 0,strpos($a,"&"));
}
// we have the results.
$mygooglekeyword = urldecode($a);
}
Google initiated SSL for all searches and the information is only available via Google Analytics.
However, for paid campaigns search engines like Google, Bing and Yahoo use query string parameters such as utm_parameters and you can access the search query from the parameter utm_term.
This is the first time I have came in contact with JSON, and I literally have no idea how to parse it with PHP. I know that functions to decode JSON exist in PHP, but I am unsure how to retrieve specific values defined in the JSON. Here's the JSON for my app:
http://itunes.apple.com/search?term=enoda&entity=software
I require a few values to be retrieved, including the App Icon (artworkUrl100), Price (price) and Version (version).
The things I am having issues with is putting the URL of the App Icon into an actual HTML image tag, and simply retrieving the values defined in the JSON for the Price and Version.
Any help/solutions to this would be fantastic.
Thanks,
Jack
Yeah, i have something similar, for my App review website, here is a bit code:
$context = stream_context_create(array('http' => array('header'=>'Connection: close')));
$content = file_get_contents("http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/wsLookup?id=$appid&country=de");
$content = json_decode($content);
$array = $content->results["0"];
$version = $array->version;
$artistname = $array->artistName;
$artistid = $array->artistId;
Thats what I used to get Information from the AppStore, maybe you can change the link and some names and it would work for you.
In Short, I am pulling the feed from my blogger using the Zend API in PHP. I need to get the URL that will link to that post in blogger. What is the order of functions I need to call to get that URL.
Right now I am pulling the data using:
$query = new Zend_Gdata_Query('http://www.blogger.com/feeds/MYID/posts/default');
$query->setParam('max-results', "1");
$feed = $gdClient->getFeed($query);
$newestPost = $feed->entry[0];
I can not for the life of me figure out where I have to go from here to get the URL. I can successfully get the Post title using: $newestPost->getTitle() and I can get the body by using $newestPost->getContent()->getText(). I have tried a lot of function calls, even ones in the documentation and most of them error out. I have printed out the entire object to look through it and I can find the data I want (so I know it is there) but the object is too complex to be able to just look at and see what I have to do to get to that data.
If anyone can help me or at least point me to a good explanation of how that Object is organized and how to get to each sub object within it, that would be greatly appreciated.
EDIT: Never mind I figured it out.
You are almost there, really all you need to do is once you have your feed entry is access the link element inside. I like pretty URLs so I went with the alternate rather than the self entry in the atom feed.
$link = $entry->link[4]->href;
where $entry is the entry that you are setting from the feed.
The solution is:
$query = new Zend_Gdata_Query('http://www.blogger.com/feeds/MyID/posts/default');
$query->setParam('max-results', "1");
$feed = $gdClient->getFeed($query);
$newestPost = $feed->entry[0];
$body = $newestPost->getContent()->getText();
$body now contains the post contents of the latest post (or entry[0]) from the feed. This is just the contents of the body of the post, not the title or any other data or formatting.
I wanted to write a function for grabbing all tweets for specified user, but it returns only 20 most recent.
I came up with something like that:
function getTweets($user) {
$page = file_get_contents("http://twitter.com/{$user}");
$from = strpos($page, "<ol id='timeline' class='statuses'>");
$to = strpos($page, "</ol>");
$length = $to - $from;
$page =substr($page, $from, $length);
echo $page;
}
getTweets('user_name');
Is there a way to get round that?
Twitter has an API that you should be querying to retrieve data such as tweets. It is far more efficient than crawling the HTML.
The statuses/user_timeline API service returns a list of tweets from any non-protected user. Here's an example of this service, configured to retrieve tweets for the user FRKT_ (that's me). You can customize the data it returns in many ways, such as by appending the count variable to the URL like so to specify how many tweets you'd like to retrieve.
You should use an XML parser such as SimpleXML rather than miscellaneous string functions such as strpos like you demonstrated to parse the data returned from the API.
Twitter Libraries has libs for php listed. If you can grab a single users all tweets or not I'm afraid I don't know but the libs should be a good starting point.
They only return a maximum of 3200 tweets per user by calling GET statuses/user_timeline, for more info look here:
https://dev.twitter.com/discussions/1157